由于连续的ajax调用,会话无效不起作用
我的应用程序每 3 分钟向服务器发送一次简单的 ajax http 请求。
而且由于 ajax 请求更新 httpd 会话信息,会话超时不起作用,即使
我设置了 30 分钟的默认会话超时。
有什么方法可以避免使用连续的ajax请求更新httpd会话超时信息?
我希望 http 会话在 30 分钟后失效,无论连续的 ajax 请求如何。
My application sends simple ajax http request to server every 3 minutes.
And because ajax request update httpd session info, session timeout is not working, even
though I set 30 minute default session timeout.
Is there any way to keep away from updating httpd session timeout info with continuous ajax request ?
I want http session invalidate after 30 minutes, regardless of continuous ajax request.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以创建一个以时间戳作为值的会话变量。
每次用户请求页面时,您都可以更新时间戳。
除非是 Ajax 请求。
每次发生 Ajax 请求时,您都可以检查是否已过去 30 分钟,如果已过去,则销毁会话。
这是我能想到的唯一方法。
You can create a session variable with a timestamp as value.
Everytime a user request a page you can update the timestamp.
Except when it is the Ajax request.
Everytime the Ajax request takes place you can check whether 30 mins have gone by and if so destroying the session.
That´s the only way I can think of.