i’m setting a cookie using this code:
setcookie("Blah","user",time()+86400);
i’m then checking that cookie on another page and setting another cookie, then redirecting to another page
if (isset($_COOKIE["Blah"]))
{
setcookie("Demo","user",time()+86400);
}
$url="cd/bar/home.php"
header ("Location: $URL");
however, when it gets to the redirected page it’s acting as if the second cookie isn’t set (if it matters the second page is in a different subdirectory, so i’m going from .com/fu/home.php to .com/bar/home.php)
on the redirected page i’ve got this checking the second cookie
<?php
if (isset($_COOKIE["Demo"]))
{
?>
html
<?php
}
?>
i have no idea why it’s not recognizing that the cookie is set. i know for a fact that the check for the first cookie is working as expected.
From the manual page for
setcookie:So the cookie is only being set with the
/fu/path. If you want to set it to the global path, say so explicitly: