Re: setcookie() failure
| From: | Richard Lynch | Date: | Mon, 26 Aug 2002 23:29:55 +0000 |
| Subject: | Re: setcookie() failure | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-114202@lists.php.net to get a copy of this message | ||
>Can anyone tell me why the following setcookie()s fail?
>$expDate = mktime(12, 50, 30, 6, 20, 2010);
>setcookie("tzusercookie", $uid, $expDate);
>setcookie("tzpasscookie", $password, $expDate);
Among other stupidities, some versions of IE require that you provide *both*
date and directory, or *neither*, but not just the date.
In addition, Cookie expirations more than 2 years in the future are assumed
by some browsers (and by the Cookie spec) to be BOGUS, so 2010 is going to
mess up some browsers.
It's also a Bad Idea to bury 2010 in there anyway. What's gonna happen if
this code actually survives through 6/20/2010? Bam! It breaks for no
apparent reason and some poor schnook (maybe you) has to go figure out why.
Use $expDate = time() + 60*60*24*365*2; for the maximum two-year Cookie
time-out. (Roughly two years, natch.)
--
Like Music? http://l-i-e.com/artists.htm