当前位置: 代码迷 >> Java Web开发 >> 怎么用代码做到当前用户登录了,不能再做到第二次登录
  详细解决方案

怎么用代码做到当前用户登录了,不能再做到第二次登录

热度:8   发布时间:2016-04-17 16:42:25.0
如何用代码做到当前用户登录了,不能再做到第二次登录
个位高手,请问如何用代码做到:当一个用户登录后,当他再次在同一电脑上登录时登陆不上去,或者在其他的电脑上也登陆不上去啊!

------解决方案--------------------
登陆的时候:
if (application.getAttribute(userid) != null) {
System.out.println( "You have logined! ");
} else {
application.setAttribute(userid,userid);
System.out.println( "You are welcome! ");
}

退出的时候:
application.removeAttribute(userid);

如果你还要问其他问题,把这个贴结了,重新开个100分的。
  相关解决方案