Google Chrome maximum cookie expiry date

自闭症网瘾萝莉.ら 提交于 2019-12-10 13:15:53

问题


I was creating my website when I created a new cookie with this php line :

setcookie('subscribed', 'true', time() + 365*24*3600*100, '/', null, false, true);

I realised my browser (Google Chrome) refused to get that cookie. When I looked at my cookies in Google Chrome it wasn't there. I started fiddling with the different settings until I saw that this worked :

setcookie('subscribed', 'true', time() + 365*24*360, '/', null, false, true);

Which meant that changing the expiration time to a lower value did work as a means of making this work.

My question is, what is the lowest expiration time you can set for a cookie in Google chrome? Does anyone know of this policy?


回答1:


I have just tried that on a 64bit OS with Chrome as a browser and Apache as a server, and it works flawlessly. It shows the cookie's expiration time to be somewhere in the year 2113.

dev-null-dweller is probably right: Any date beyond 03:14:07 UTC on Tuesday, 19 January 2038 will wrap around to some time close to 1900, thus forcing the cookie to immediately disappear (on 32bit platforms, that is).

Work around this by setting cookie expiration times to be no more than 10 years in the future, or so. This is already beyond the reasonably expectable lifetime of any electronic device, which will hold it, anyways.



来源:https://stackoverflow.com/questions/16626875/google-chrome-maximum-cookie-expiry-date

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!