We're supporting legacy code that is dropping a cookie and setting the expiration to DateTime.MaxValue:
HttpCookie cookie = new HttpCookie(cookieName, value);
cookie.Expires = DateTime.MaxValue;
It seems that on some browsers (which we are not logging), this cookie expires immediately--or may not even be getting dropped. According to MSDN, DateTime.MaxValue is December 31, 9999. Are there any browser-related issues with setting a cookie expiration to this date?
The correct answer would be to change the expiration date, but at this point, we can't change production code.
This can be done easily by adding expires=expirationDate in UTC separated by semicolon from the name=value, as seen in the following example: document. cookie = "username=Max Brown; expires=Wed, 05 Aug 2020 23:00:00 UTC"; document.
Cookies without an Expires or Max-Age attribute are treated as session cookies, which means they are removed once the browser is closed. Setting a value on either Expires or Max-Age makes them permanent cookies, since they will exist until they hit their expiry date.
Or you might use mktime(). time()+60*60*24*30 will set the cookie to expire in 30 days. If not set, the cookie will expire at the end of the session (when the browser closes). The path on the server in which the cookie will be available on.
When cookies are set with an explicit Expires/Max-Age attribute the value will now be capped to no more than 400 days in the future. Previously, there was no limit and cookies could expire as much as multiple millennia in the future.
If I had to randomly guess why it's not working, I would say it has something to do with Unix epoch time. This value will technically overflow (on 32-bit machines) after January 19, 2038 at 3:14:07 AM GMT - so the next second after this would be interpreted as January 1, 1970 0:00:01 AM GMT.
It's possible that the future time you've supplied is actually converted into a past time.
Again, this is a complete guess and hopefully I can test it soon when VWD Express 2008 is downloaded on my home machine.
Searching for this issue, I have found a similar error:
http://framework.zend.com/issues/browse/ZF-5690
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With