cannot retrieve cookie
Posted: Tue Jul 11, 2006 1:58 am
who ate my cookie?
Hi, i'm a supernoobie in php.
I set cookie using setcookie, but when i try to retrieve, it gave me nothing.
and then to check if it works, i used this code in the body of html tags
I also checked $_GET and $_POST they are all fine but the cookie. who took my cookie??
Hi, i'm a supernoobie in php.
I set cookie using setcookie, but when i try to retrieve, it gave me nothing.
Code: Select all
<?php
$ret = setcookie('username', 'admin', mktime()+120, '/');
if (!ret) {
echo "unable to set cookie";
}
else {
echo "cookie is set";
}
?>Code: Select all
<?php
print_r($HTTP_COOKIE_VARS);
print_r($_COOKIE);
?>