I don't remember having many problems using Cookies in the past but I was playing around and encountered some unexpected results.
(i'm running on localhost, hence my domain setting)
<?php
$sessionCookie = rand();
setcookie("crav_auto_login_cookie", $sessionCookie, false,"/crav/", false);
echo "Cookie Set<br/>";
echo "Cookie equals: ".$_COOKIE["crav_auto_login_cookie"]."<br/>";
echo "should equal: ". $sessionCookie;
?>
This will yield in the following output:
Cookie Set
Cookie equals: 457718770
should equal: 318511886
I am obviously missing something, but not sure why the values are different. Is it because cookies are loaded on page call, and $_COOKIE["crav_auto_login_cookie"]
is returning the results from the instance called when the page is opened and not reflecting the newly set value? If that is the case, then why?