NYCPHP Meetup

NYPHP.org

[nycphp-talk] How do I create a future date for a cookie?

Chris Shiflett shiflett at php.net
Thu Sep 4 15:33:51 EDT 2003


--- David Sklar <sklar at sklar.com> wrote:
> Note that many browsers won't deal well with an cookie whose
> expiration date is after January 19, 2038 at 3:14:07 A.M. UTC
> (that's an epoch timestamp of 2147483647) since they store cookie
> expiration time in a 32 bit signed integer. (The maximum positive
> value of a 32 bit signed int is 2147483647).
> 
> So, you may be better off with:
> 
> setcookie('myCookie',$val,2147483647);

That's a good point.

Also of note is that the cookie specification does not allow a cookie's
expiration date to be more than two years in the future, so a cookie should
never be allowed to persist for more than two years. I'm honestly not sure how
strictly this is implemented across the various browsers; maybe someone with
some free time can use David's code and test. :-)

Chris

=====
Become a better Web developer with the HTTP Developer's Handbook
http://httphandbook.org/



More information about the talk mailing list