if (isset($_GET['show'])) {
// Delete the cookie (note: it will still be set in $_COOKIE).
setcookie('test');
echo 'Cookie was: ';
if (isset($_COOKIE['test']) && ($_COOKIE['test'] == $_GET['show'])) {
echo 'SET';
} else {
echo 'NOT SET';
}
// Make sure this is a new url. This is needed for 301 responses which are otherwise cached.
echo '
try again';
} else {
$id = microtime(true);
setcookie('test', $id, time() + 4);
header('Location: ?show=' . $id, true, 302); // Could also use 301.
}