• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Browser closing detection for session handling

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I know that this post perhaps belongs to the javascript forum, but I need some help to invalidate a session.

Currently I have used HttpSessionListener to find if the session has timed out or the user has used the logout button.

What I want to do is to detect when the user closes the tab/window where my application is, in order to destroy the session, so he/she can log again if the user opens another window (only one session per user is allowed).

I know that in Firefox I can use the onclose event to send that information to the server, but I also need to do it in Internet Explorer and chrome (at least).

Care to share any suggestions? Thank you very much in advance.
 
Sheriff
Posts: 67746
173
Mac Mac OS X IntelliJ IDE jQuery TypeScript Java iOS
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Welcome to the Ranch.

Please SearchFirst. You will find that this issue has been discussed dozens of times, and that the conclusion is always that you cannot detect when the browser is closing, and you must rely on the session timeout to allow the session to invalidate itself when the timeout expires.
 
Ricardo Celma
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
thank you very much.
 
reply
    Bookmark Topic Watch Topic
  • New Topic