会话什么时候过期?
我在 web.xml 中将会话超时设置为 5 分钟。一旦会话过期,sessionDestroyed() 将被执行。
但我希望只要浏览器窗口仍然存在,会话就处于活动状态。因此,在每个 JSP 页面中都有一段 JavaScript 代码,每 100 秒访问一次服务器上的图像。有关这部分的基本想法可以在以下位置找到 http://www.intelliproject.net/articles/showArticle/index/js_session_expired
但是,sessionDestroyed() 仍然会在 5 分钟后执行。这是我的问题,为什么即使我每 100 秒访问一次 sessionTimeout 事件,它也会被触发?
I set session timeout to be 5 minutes in web.xml. And once session expired sessionDestroyed() will be executed.
But I want session to be alive as long as browser window is still there. So in each JSP page there is a piece of JavaScript code that visits an image on the server every 100 seconds. Basic idea regarding this part can be found at
http://www.intelliproject.net/articles/showArticle/index/js_session_expired
However, the sessionDestroyed() will still be executed in 5 minutes. Here is my question, why sessionTimeout event is triggered even though I keep visiting it every 100 seconds?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
使用 firebug,打开网络选项卡并观察 JavaScript 请求。您应该为每个图像 GET 接收
HTTP 200
,并且每个 url 末尾都应附加随机数。您可能应该只使用时间戳,而不是随机数,因为随机数最终可能会重复并导致用户注销。您有发生这种情况的示例页面吗?
Using firebug, open the net tab and watch for the javascript request. You should be receiving
HTTP 200
for each image GET, and each url should have random numbers appended to the end. You should probably just use a timestamp, rather than random numbers, as random numbers might eventually repeat and log the user out.Do you have an example page where this is happening?