Recently I posted about using a bit of PHP to check whether a user has cookies enabled (post is here ). Now my client is telling me he's getting the "no cookies" page, though he's checked that Firefox (XP) has cookies enabled. My exact implementation looks like this:
if (!isset($_GET['testcookie']) and !isset($_COOKIE['test']))
{
setcookie("test", time(), time()+3600);
header('location: '.$_SERVER['PHP_SELF'].'?testcookie=1');
}
if (isset($_COOKIE['test']))
{
$page->set('content', $content->fetch('login.tpl.php'));
}
else
{
$page->set('content', $content->fetch('no_cookies.tpl.php'));
}
Ya know - I bet he's bookmarked the URL FOLLOWING the test - to wit:
https://www.site.com/admin/index.php?testcookie=1
If he hit that URL and the cookie was expired, he'd get the "no cookies" message.
So...hmmm...how do I account for those who bookmark the post-test URL? It's like I need another test - it needs to loop twice or something.
Any bright thoughts on a way to do this sanely?