note 51421 added to function.setcookie
| From: | DaineMamacos at osu1 dot php dot net | Date: | Wed, 30 Mar 2005 16:14:10 +0000 |
| Subject: | note 51421 added to function.setcookie | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-87188@lists.php.net to get a copy of this message | ||
I found with Internet explorer (ver 5 and 6) that I was unable to delete cookies by setting the
expiry to 1 (1 second after the epoch). This was causing me headaches because it worked with every
other browser except for internet explorer. The solution, though timely and weird, I figured out was
that (as far as I can figure) M$ don't consider 1970 the epoch, they consider 1980 the epoch.
Or something like that.
So to expire a cookie on internet explorer you can set the expiry according to the following
formula.
//10 years less the 2 yeas which have leap years
(60*60*24*365*10) = 315360000
//add 2 extra days for the missing leap years.
315360000 + (60*60*24*2) = 315532800
So one can use this to expire a cookie:
setcookie("MyCookie", "BLAHBLAH", 315532800, "/");
I found that this number was the minimum I could set it to, one second less, and it would not expire
the cookie.
----
Manual Page -- http://www.php.net/manual/en/function.setcookie.php
Edit -- http://master.php.net/manage/user-notes.php?action=edit+51421
Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+51421&report=yes&reason=added+to+the+manual
Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+51421&report=yes&reason=bad+code
Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+51421&report=yes&reason=spam
Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+51421&report=yes&reason=useless
Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+51421&report=yes
Reject -- http://master.php.net/manage/user-notes.php?action=reject+51421&report=yes
Search -- http://master.php.net/manage/user-notes.php