[英]cookie.setMaxAge strange behaviour
I work in a jsp based website that needs cookies enabled in order to navigate it (It is an internal site, it will not be exposed to the internet). 我在一个基于jsp的网站上工作,该网站需要启用cookie才能进行导航(它是一个内部网站,不会暴露于Internet)。
The first visit of a user will return a 302 to the same url that was requested, and set a cookie for an hour. 用户的首次访问将返回302到所请求的相同网址,并设置一个小时的cookie。
I am using Cookie.setMaxAge(60*60);
我正在使用Cookie.setMaxAge(60*60);
to set the expiry date. 设置到期日期。
I am having a really weird behaviour with some versions of some browsers where they keep redirecting forever. 在某些版本的浏览器中,它们永远重定向,我的行为很奇怪。 (Some work, some don't work). (有些工作,有些不工作)。
After a lot of investigation, we've discovered that the time in the server is not set to the correct time, and it has its time set to two hours and a half in the past, rsulting on that the cookie may "expired" as it is set. 经过大量调查,我们发现服务器中的时间未设置为正确的时间,并且将其时间设置为过去的两个半小时,结果导致Cookie可能“过期”,因为它被设置。 (here's my doubt) (这是我的疑问)
Unfortunately this is a production server and I cannot change it easily (it's being requested but it will take some time). 不幸的是,这是一台生产服务器,我无法轻松对其进行更改(有人提出要求,但需要一些时间)。
Just to confirm this was the issue, I changed the time of a client machine to two hours and a half in the past and it started to work fine in that machine. 为了确认这是问题所在,我将客户端计算机的时间更改为过去两个半小时,并且开始在该计算机上正常工作。
My questions are : 我的问题是:
[EDIT] [编辑]
After reading RFC 6265 as Arham suggest, the expiry date can be set by the server as absolute or relative. 在按照Arham的建议阅读RFC 6265之后,服务器可以将到期日期设置为绝对或相对。 In case both are presenr, relative takes precedence. 如果两者都存在,则以亲戚为准。 The appserver I am using is setting the cookie with the absolute value (which is probably wrong), so I don't understand how it is working on some browsers. 我正在使用的应用服务器将cookie设置为绝对值(这可能是错误的),因此我不了解它在某些浏览器中的工作方式。
[/EDIT] [/编辑]
Thanks in advance. 提前致谢。
How about javascript cookies? javascript cookie呢?
http://www.w3schools.com/js/js_cookies.asp http://www.w3schools.com/js/js_cookies.asp
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.