• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

How to check is session has been invalidated due to session time out

 
jishnu dasgupta
Ranch Hand
Posts: 103
Eclipse IDE Java Netbeans IDE
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I need a way to determine, if my session has been invalidated due to session time out. I have a HttpSessionBindingListenner, which has a valueUnbound() interface, which gets called whenever my session is invalidated. However, my session is invalidated, both when my user Logs off, as well as when he crosses the session timeout limit.
Is there as way where I can uniquely identify, when my session has been invalidated due to session timeout.

I have already implemented a logic, in valueUnbound(), where i check the timestamp of the session's creation time as compared to the current timestamp, and determine if the difference is more than or same as the session timeout parameter. However, is there any alternative for the same.
 
Devaka Cooray
Marshal
Pie
Posts: 4879
402
Chrome Eclipse IDE Google App Engine IntelliJ IDE jQuery Postgres Database Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
jishnu dasgupta wrote:.... both when my user Logs off...

Add an attribute to the session every time the user explicitly logs out, so you can track its existence from the listener.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic