// Starting the session session_start(); // Retrieving the session ID $sessionId = session_id(); // Retrieving the session unique identifier $sessionUID = $_SESSION['uid']; // Displaying the session ID and unique identifier echo "Session ID: $sessionId"; echo "Session UID: $sessionUID";
// Starting the session session_start(); // Checking if the session UID exists if (!isset($_SESSION['uid'])) { // Generating a new UID $uid = uniqid(); // Storing the new UID in the session $_SESSION['uid'] = $uid; } // Retrieving the session UID $sessionUID = $_SESSION['uid']; // Displaying the session UID echo "Session UID: $sessionUID";In this example, we start the session and check if a session UID is already set. If not, we generate a new unique identifier using the `uniqid()` function and store it in the session using the 'uid' key. We then retrieve the session UID using the `$_SESSION` global variable and display it on the screen. Package Library: PHP Standard Library.