java - how to insert value in DB when session is expired -


in work login, use authentication jsp page setting max inactive time 60 prevent multiple logins single username.

i have created field status in db when user logs in status active , no other user can login same username.

now problem how set status inactive in db when session expires.

to update status inactive did

login=(string)session.getattribute("login");  preparedstatement pt = con.preparestatement("update authentication set status='inactive' username='"+login+"'"); 

so when session expired, login give null. please tell me how solve problem

use httpsessionactivationlistener

     public void sessiondidactivate(httpsessionevent se)  

notification session has been activated.

     public void sessionwillpassivate(httpsessionevent se)  

notification session passivated.

or

httpsessionlistener

     sessioncreated(httpsessionevent se)  

receives notification session has been created.

     sessiondestroyed(httpsessionevent se)  

receives notification session invalidated.


Comments

Popular posts from this blog

php - Why I am getting the Error "Commands out of sync; you can't run this command now" -

linux - Does gcc have any options to add version info in ELF binary file? -

java - Are there any classes that implement javax.persistence.Parameter<T>? -