Error setting cookie before DateTime.Max (December 31, 9999)?

We support legacy code that rejects cookies and sets the expiration dateTime.MaxValue:

HttpCookie cookie = new HttpCookie(cookieName, value); cookie.Expires = DateTime.MaxValue; 

It seems that in some browsers (which we do not register) this cookie expires immediately - or even cannot be dropped. According to MSDN, DateTime.MaxValue is December 31, 9999. Are there any problems with the browser setting the cookie expiration date on this date?

The correct answer would be to change the expiration date, but at this point we will not be able to change the production code.

+4
source share
1 answer

If I had to accidentally assume why it does not work, I would say that it has something to do with the Unix era . This value will be technically overflowed (on 32-bit machines) after January 19, 2038 at 3:14:07 GMT - so the next second after that will be interpreted as January 1, 1970 0:00:01 GMT.

It is possible that the future tense that you have provided is actually being transformed into the past.

Again, this is a complete hunch, and I hope I can check it out soon when VWD Express 2008 is loaded on my home machine.

Edit:

Searching for this problem, I found a similar error:

http://framework.zend.com/issues/browse/ZF-5690

+7
source

All Articles