Cookie过期与服务器的会话过期时间有关吗?

Cookie过期与服务器的会话过期时间有关吗?,第1张

概述使用下面的代码设置Cookie, document.cookie = name“=”value“; expires =”“domain = xyz.com; path = /”; 在我的服务器中设置的会话到期时间是15分钟.如果客户闲置15分钟, 15分钟后,会议将被销毁.这会破坏我的Cookie中设置的值吗? 我的意思是,在document.cookie中设置的cookie过期是否与服务器中设置 使用下面的代码设置cookie,

document.cookie = name“=”value“; expires =”“domain = xyz.com; path = /”;

在我的服务器中设置的会话到期时间是15分钟.如果客户闲置15分钟,
15分钟后,会议将被销毁.这会破坏我的cookie中设置的值吗?

我的意思是,在document.cookie中设置的cookie过期是否与服务器中设置的cookie过期有关?

解决方法 我认为答案实际上取决于浏览器如何处理cookie过期.

当服务器发送http响应时,客户端(浏览器)将在响应中查找任何Set-cookie标头.如果找到,它将覆盖存储在浏览器上的cookie.

引自Persistent Client State HTTP Cookies:

The expires header lets the clIEnt kNow when it is safe to purge the mapPing but the clIEnt is not required to do so. A clIEnt may also delete a cookie before it’s expiration date arrives if the number of cookies exceeds its internal limits.

另外,检查一下:

If a CGI script wishes to delete a cookie,it can do so by returning a cookie with the same name,and an expires time which is in the past. The path and name must match exactly in order for the expiring cookie to replace the valID cookie. This requirement makes it difficult for anyone but the originator of a cookie to delete a cookie.

这意味着如果Web服务器自动向您发送带有Set-cookie标头的响应,它将覆盖您手动设置的cookie.

有关:
http://www.superuser.com/questions/356265/what-do-browsers-do-with-expired-cookies
http://www.stackoverflow.com/questions/1635909/how-do-i-remove-delete-expire-a-cookie-immediately

总结

以上是内存溢出为你收集整理的Cookie过期与服务器的会话过期时间有关吗?全部内容,希望文章能够帮你解决Cookie过期与服务器的会话过期时间有关吗?所遇到的程序开发问题。

如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。

欢迎分享,转载请注明来源:内存溢出

原文地址:https://54852.com/web/1054683.html

(0)
打赏 微信扫一扫微信扫一扫 支付宝扫一扫支付宝扫一扫
上一篇 2022-05-25
下一篇2022-05-25

发表评论

登录后才能评论

评论列表(0条)

    保存