杀死用户会话 [英] Kill user session

查看:87
本文介绍了杀死用户会话的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆