• Post Reply Bookmark Topic Watch Topic
  • New Topic

invalidate a session

 
Confused
Ranch Hand
Posts: 54
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i want to invalidate a session whenever a user will close the browser from the jsp.

could you guild me on this

thanks in advance
 
Seetharaman Venkatasamy
Ranch Hand
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi piyali,

when the user click close button,just use session.invalidate()

or session.setMaxInactiveInterval(0)..then redirect to logout page

Thanks & Regards,
seetharaman.v
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You can't, at least not reliably.

The server has no way of knowing if the user has browsed to a different site, closed their browser, lost their internet connection, had their PC crash on them, etc.... This is why sessions are designed to time out after a pre-determined amount of time.

You can add a logout button to your application, which can make a request to a servlet or JSP that calls session.invalidate() but, if the user doesn't explicitly click it, you have to wait for the session to timeout.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!