杀死用户会话 [英] Kill user session
问题描述
我有3个标签。主页,tab1,tab2。当用户启动应用程序时,它会定向到主页选项卡&我使用创建一个新会话HttpSession session = request.getSession();
当用户浏览其他标签时,我使用维护会话HttpSession session = request.getSession(false);
现在,如果用户单击主页选项卡,我想要销毁上一个会话并以新会话重新开始。请告诉我怎么做?
I have 3 tabs. Home, tab1, tab2. When user launches the app, its directed to Home tab & I create a new session using HttpSession session = request.getSession();
When user browses to other tabs, I maintain the session using HttpSession session = request.getSession(false);
Now if the user click back on Home tab, I want to destroy the previous session and start fresh with new session. Please tell me how to do it?
推荐答案
用
HttpSession session = request.getSession();
if (!session.isNew()) {
session.invalidate();
session = request.getSession();
}
然而这有点奇怪。我宁愿在会话中放置一个属性,然后拦截它的存在。
This is however a bit odd approach. I would rather put an attribute in the session and then intercept on its presence instead.
这篇关于杀死用户会话的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!