Set-Cookie: Expire property, clock skew and Internet Explorer issue

前端 未结 4 1563
北恋
北恋 2020-12-05 21:42

There is a header Max-Age that allows to specify the expiration time of a cookie. Unfortunately Internet Explorer 6, 7, 8 and probably later do not support Max-Age and requi

4条回答
  •  广开言路
    2020-12-05 22:09

    What i did was to shift the time keeping to server side.You can never be sure of the time in client side, but you know your server never lies.

    • You keep the time that the first request happened on the server(keep server time when you send data per client), and you set a cookie with a max date expiration i.e. :01/01/2900.
    • You keep track of that time and in lets say 10 minutes server time you decide its time to kill it.
    • You then set the cookie to have the min date then. i.e. 01/01/1900. Deleting cookies :
      http://msdn.microsoft.com/en-us/library/ms178195(v=vs.100).aspx

提交回复
热议问题