Page 1 of 1
Cookie help.
Posted: Sun Apr 16, 2006 12:39 am
by Xom
I am try set a cookie with setcookie and it works fine but it always return true even if I disable cookies in my browser. So do you know what is happening any to fix this is there a other to check if the cookie got set or am I doing this totally wrong?
Posted: Sun Apr 16, 2006 12:44 am
by John Cartwright
showing us the code helps

Posted: Sun Apr 16, 2006 12:58 am
by Xom
<?php
$passed = setcookie("name","value",time()+604800);
echo($passed);
?>
$passed always equals 1 even if the cookie was not set.
Posted: Sun Apr 16, 2006 1:09 am
by feyd
Reading the documentation would have told you why it returns 1
If output exists prior to calling this function, setcookie() will fail and return FALSE. If setcookie() successfully runs, it will return TRUE. This does not indicate whether the user accepted the cookie.
Posted: Sun Apr 16, 2006 1:12 am
by Xom
Oh, I feel stupid. So how can I figure if the user accepted the cookie or not?
Posted: Sun Apr 16, 2006 1:14 am
by feyd
The cookie data is present on the next page request.