Reputation:
In my work from login, I use an authentication jsp page where I am setting the max inactive time as 60 to prevent multiple logins from a single username.
I have created a field status
in DB so when a user logs in then the status will be active and no other user can login from the same username.
Now my problem is how to set the status as inactive in the DB when the session expires.
To update status inactive I did
login=(String)session.getAttribute("login");
PreparedStatement pt = con.prepareStatement("update authentication set status='inactive' where username='"+login+"'");
So when the session is expired, then login will give null. Please tell me how to solve my problem
Upvotes: 1
Views: 342
Reputation: 121998
Use HttpSessionActivationListener
public void sessionDidActivate(HttpSessionEvent se)
Notification that the session has just been activated.
public void sessionWillPassivate(HttpSessionEvent se)
Notification that the session is about to be passivated.
or
sessionCreated(HttpSessionEvent se)
Receives notification that a session has been created.
sessionDestroyed(HttpSessionEvent se)
Receives notification that a session is about to be invalidated.
Upvotes: 2