启用反向 Ajax 时 httpsession 不会过期
我有一个使用 DWR 反向 Ajax 的 Web 应用程序(pollAndCometEnabled 设置为 true) 在我的 web.xml 中,我为 HttpSession 设置了 30 分钟的超时。 由于 DWR 轮询服务器,因此 http 会话始终处于活动状态,结果是它永远不会过期,即使用户的交互超过 30 分钟处于非活动状态也是如此。 有谁知道如何解决这个问题?
I have a web application that uses DWR reverse Ajax (pollAndCometEnabled set to true)
In my web.xml i have set a timeout of 30 minutes for the HttpSession.
Since DWR polls the server, the http session is always active and the result is that it never expires, even if the user's interaction is inactive for over 30 minutes.
Does anyone knows how solve this problem?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我可以为您想到 3 种不同的选择...
1) 将您的 comet 请求保留在不使用会话 cookie 的域上;作为附带好处,您还可以减少请求开销
2) 监视客户端的超时。根据您的应用程序设置,这可能有点麻烦,但 setTimeout 是一个非常简单的解决方案;缺点是,您并没有真正使它们过期,因此会话在技术上对服务器仍然有效,但好处是您可以轻松地向他们发出“您的会话即将过期”警告。
3) 监控服务器的活动;由于您使用的是 Comet 解决方案,因此您可以监视服务器上的会话,并且当会话到期时,向客户端推送一条消息,通知他们会话已结束。如果您无法切换域,这是最好的选择,因为您可以丢弃服务器上的会话,同时让客户端知道。
I can think of 3 different options for you...
1) keep your comet requests on domain that doesn't use session cookies; as a side benefit, you'll also reduce your request overhead
2) monitor the timeout on the client side. depending on your application setup, this might be a bit more of a chore, but a setTimeout is an incredibly simple solution; downside is, you're not really expiring them, so the session is technically still valid to the server, but the upside is you can easily give them a nice "your session is about to expire" warning.
3) Monitor the activity from the server; since you're using a comet solution, you can monitor the sessions on the server, and when the session is expiring, push a message to the client notifying them that the session has ended. This is the best option if you can't switch domains, because you can trash the session on the server, and let the client know at the same time.