preventing multiple user login for same user in java
I am using java wit开发者_JAVA百科h struts2 framework .and sqlserver 2005 database . i need help in preventing multiple user login with same username. i tried using session .. m new to this framework . if any one could help me it will be great . i did by using a flag in database and setting it to true .. and while logout it will be set to false .. but the problem i got is when some user accidently close the browser or some other interrupt happens .. the user will not be able to log in ...m totally confused wat method should i use ..i dint use any session or cookies .. if there s any simple method is there pls help me out of this ..
Maintain application map with logged in user. if any user try to create different session with the same userid invalidate her session.
Spring Security handles this easily, maybe you can give it a try.
I think you should be using Sessions for such cases.
Accessing DB is an overhead.
This is a good tutorial to start with Session Management.
i did by using a flag in database and setting it to true .. and while logout it will be set to false
This is not the way sessions should be handled. Use cookies or other proper session handling techniques.
http://www.roseindia.net/struts/struts2/struts2-login.shtml
Tutorials are available!
i think you can start one thread this update current time stamp in user master table after some time interval
if same user login from different browser you can check user master table timestamp and current server time gap more than interval
if not don't allow user to login
精彩评论