简体   繁体   English

在小门中的运行时覆盖会话超时

[英]Override Session timeout at runtime in wicket

How can I override session timeout interval during the runtime. 如何在运行时覆盖会话超时间隔。 Basically at the time of login, user is given an option if wants to be logged in for specific hours say(7). 基本上在登录时,如果要在特定时间登录,用户将获得一个选项,例如say(7)。

So what I did once user is authenticated , set the max inactiveInterval at the session. 因此,一旦用户通过身份验证,我所做的就是在会话中设置最大inactiveInterval。

WebRequest request = (WebRequest) WebRequestCycle.get().getRequest(); WebRequest request =(WebRequest)WebRequestCycle.get()。getRequest(); request.getHttpServletRequest().getSession().setMaxInactiveInterval(HOURS * 60); request.getHttpServletRequest()。getSession()。setMaxInactiveInterval(HOURS * 60);

but this doesn't seems to work . 但这似乎没用。 User is still logged on after that time. 在那之后用户仍然登录。

Thanks! 谢谢!

Pratik 普拉蒂克

I believe the name of the method would speak for itself. 我相信方法的名称会说明一切。 setMaxInactiveInterval() would surely wait for a period of time after the last response before expiring the session, so your session would have been kept alive for 7 hours after the last response? setMaxInactiveInterval()肯定会在上次响应后等待一段时间,直到会话到期,因此您的会话在上次响应后会保持7个小时的生命吗?

As for the answer, you're probably looking at something either within the page or within the session that checks against a pre-defined time to see if its longer than the pre-defined period. 至于答案,您可能正在查看页面中或会话中的某个东西,这些东西对照预定时间进行检查,以查看其时间是否长于预定时间。

Hope this helps. 希望这可以帮助。

The method takes seconds instead of minutes, but that does not explain the phenomenon. 该方法只需花费几秒钟而不是几分钟,但这并不能解释这种现象。

Maybe you can verify the session id in the cookie on your browser if it changes? 如果更改,也许您可​​以在浏览器的Cookie中验证会话ID? I have had situation where the session handling was so "robust" a brand new session was created that unless the browser pages were notified that the session was terminated, it would simply create a new one. 我曾遇到过这样一种情况,即会话处理是如此“健壮”,因此创建了一个全新的会话,除非通知浏览器页面该会话已终止,否则它只会创建一个新会话。 Now I admit that was back in my perl days and that this is extremely unlikely to happen with container manages sessions 现在,我承认那是我回到perl时代的经历,而且容器管理会话极不可能发生这种情况

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM