There is a Max-Age header that allows you to specify the expiration time of the cookie. Unfortunately, Internet Explorer 6, 7, 8 and possibly later do not support Max-Age and require the Expires header with an absolute date in GMT.
Often there may be incorrect GMT and TZ time settings for a particular client. Consider a user who has not defined his time zone and manually adjusted the clock.
Moreover, sometimes there can be a significant skew of hours in a few minutes that the user does not know about them.
In this case, GMT time can be shifted by several hours. Effectively, this would prevent the server from setting any cookie that requires a short expiration time. Consider that a cookie with a maximum age of 10 minutes will never be set if TZ is incorrect.
Original ideas on how to solve the problem (which does not work or is problematic):
- Of course, it’s best to use Max-Age, or even specify both, since all browsers will ignore the “Expire” part, but it doesn’t work in IE
- Another way I thought was to set Date: the title, hopefully IE will know to calculate the difference, to work with skewed clocks ... But that doesn't help IE.
- Get the time from the client on demand (using JavaScript) and then calculate the difference in hours and then adjust the Expire header as needed. However, this requires complex data manipulation, including a way to send time to the server.
Questions:
- What is the best and most common practice for using Expire time for cookies in IE?
- How do you do this in your applications
Artyom
source share