Question

In my struts2 application, in the login action I am placing the user and role in the session.

I want to keep track of all the users who logged in so as to do stuff like following :

  1. Avoid multiple login of same user-id.
  2. Check wheather a user is looged in or not ! Or any body with role Admin is logged in or not !
  3. and in some other actions !

How to do it any suggestion!

And also how to maintain the issues like

  • User close browser without loggin ! etc

Any material with more information of session can also realy help !

No correct solution

OTHER TIPS

You can have a column in you user table called logged_in_time (timestamp type) and update it with the time when user logs in and make it null when user logs out.

  • Avoid multiple login of same user-id: : check if this columns alreadt has some value or not.
  • Check whether a user is looged in or not : check if that column is null or not.
  • User close browser without logging out : A schduler job may be, that runs at fixed interval of time to check the session(using sessionid may be) of the user and update this field accordingly.

Take a look at this discussion for further information. And another one.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top