views:

93

answers:

4

hey Guys, I am using java with 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 ..

A: 

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.

pavanlimo
A: 

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!

bdhar
Please don't recommend RoseIndia tutorials. Its ugly.
chedine
But I guess it serves the purpose.
pavanlimo
+1  A: 

Maintain application map with logged in user. if any user try to create different session with the same userid invalidate her session.

org.life.java
A: 

Spring Security handles this easily, maybe you can give it a try.

Sinuhe