我的应用程序中有登录功能,
我能够将用户存储在会话中
如果他已经在同一个浏览器上登录,我也可以阻止用户登录..
但是如果signedIn用户尝试从不同的浏览器再次登录,我无法阻止他.
这是代码..
我正在使用这个
session=getThreadLocalRequest().getSession(true);
User loggedInUser = (User) session.getAttribute("user");
现在,如果loggedInUser尝试从另一个选项卡中的SAME浏览器进入应用程序,则此loggedInUser具有用户对象(这对我有用)
但是如果loggedInUser尝试从不同的浏览器进入应用程序(因此它对我不起作用),则此loggedInUser为null
这是代码..
public User signIn(String userid, String password) {
String result = "";
ApplicationContext ctx = new ClassPathXmlApplicationContext(
"applicationContext.xml");
MySQLRdbHelper rdbHelper = (MySQLRdbHelper) ctx.getBean("ManagerTie");
User user = (User) rdbHelper.getAuthentication(userid, password);
if(user!=null)
{
session=getThreadLocalRequest().getSession(true);
User loggedInUser = (User) session.getAttribute("user");
if(loggedInUser != null && user.getId() == loggedInUser.getId()){
user.setId(0);
}else{
session=getThreadLocalRequest().getSession(true);
session.setAttribute("user", user);
}
}
return user;
我正在使用JAVA,GWT