How can one verify if the session ID cookie is correctly set in PHP?

To verify if the session ID cookie is correctly set in PHP, you can use the session_id() function to retrieve the current session ID. You can then compare this session ID with the value stored in the session cookie to ensure they match. If they match, it indicates that the session ID cookie is correctly set.

// Verify if the session ID cookie is correctly set
session_start();

$sessionID = session_id();
$cookieID = $_COOKIE[session_name()];

if($sessionID === $cookieID) {
    echo "Session ID cookie is correctly set.";
} else {
    echo "Session ID cookie is not correctly set.";
}