Re: delete cookie does not work
| From: | Richard Lynch | Date: | Sat, 24 Aug 2002 23:55:35 +0000 |
| Subject: | Re: delete cookie does not work | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114005@lists.php.net to get a copy of this message | ||
>Hi there,
>
>I am having problems to delete a cookie. Assuming following code:
>
> echo 'sess: '.$_COOKIE["referrer"];
>
> #delete cookie
> setcookie ('referrer', "", time() - 3600);
>
>It should not display the value of referrer after calling this php file a
>second time, right?
>
>So the cookie still exists. How can I get rid of his value?
For most IE browser versions, if you provide a time (time() - 3600) you must
*also* provide a path:
setcookie('referrer', '', time() - 3600, '/');
Also, I'm not at all sanguine about the time() - 3600 bit...
You're essentially asking the browser to do something 6 minutes in the past.
Since web-browsers are not Time Machines, they may consider that
"impossible" and decide you must not have really meant it.
I would lost the time component entirely, and go with:
setcookie('referrer', '');
It doesn't matter how long you told the browser to keep the cookie around
when you set it before. If you tell it to kill the cookie now, it's gonna
go away.
--
Like Music? http://l-i-e.com/artists.htm