• 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

Clearing httpsession on window close, techniques?

 
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Anybody have a bag of tricks to have the session invalidated when closing the browser window.
One of the tricks that I know:
Have a hidden iframe and have it navigate to the url that invalidates the session when window closes.
 
Ranch Hand
Posts: 105
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
you can use the "onUnload" event of the body tag. Onunload you can try call the server side, which can invalidate the session object.
Hope this helps.
Sanjeev
 
Alok Pota
Ranch Hand
Posts: 185
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yeah, but onUnload also gets called when I get out of the page through valid exit points (say Clicking the Cancel button).
There needs to be an onClose event for the DHTML window object.
 
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hey,
Can U elaborate on the first technique which U suggested...
Paste the code if necessary
 
Mary Cole
Ranch Hand
Posts: 362
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Could anybody pls answer my previous posting pls
 
Ranch Hand
Posts: 5093
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The ONLY way to notify the server that the browser is no longer there or is moved to another site is to put some Javascript in the onunload event for the body tag of the page.
Here you can have the browser then call a servlet on the server which can invalidate the session.
As said, there is a potential problem in that it also gets called when you move to another page on your site, but I think there are ways to circumvent that.
I've never used the function myself.
 
reply
    Bookmark Topic Watch Topic
  • New Topic