cookies are driving me mad... please help
Posted: Tue Jul 27, 2004 11:49 am
I am trying to send a simple cookie from a PHP code.
Here is my code:
Now, I don't know what is the correct format of the domain section.
no matter which domain format I choose, the cookie gets saved on my computer successfully.
However, sometimes when I try to get the cookie using:
I get the error message saying 'cookie is missing'!!!
I am saying sometimes because the behaviour isn't fixed... sometimes it will work and sometimes not...
Help would be appreciated..
thanks
Here is my code:
Code: Select all
// should use one of the domains below
$domain = 'www.test.com';
$domain = '.test.com';
$domain = 'test.com';
setcookie('name', $value, time() + 31536000, '/', $domain);no matter which domain format I choose, the cookie gets saved on my computer successfully.
However, sometimes when I try to get the cookie using:
Code: Select all
if (!isset($_COOKIE['name'])) {
echo 'cookie is missing';
}
else {
$value = $_COOKIE['name'];
}I am saying sometimes because the behaviour isn't fixed... sometimes it will work and sometimes not...
Help would be appreciated..
thanks