• 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
Posts: 5218
512
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.
 
my overalls have superpowers - they repel people who think fashion is important. Tiny ad:
the new thread boost feature brings a LOT of attention to your favorite threads
https://coderanch.com/t/674455/Thread-Boost-feature
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!