Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Delete Session Variables & Cookies when Browser closes

Status
Not open for further replies.

LindaH

Programmer
Dec 12, 2001
42
US
I'm not sure if this should be posted in the JavaScript Forum or the .Net Forum, so I'll post in both!

My .Net Web Application Sets a couple of Session Variables and also sets a cookie. When the user logs out, the Session Variables and cookies are both wiped out; however, if the user merely closes the browser, I need to be able to delete both the cookie and the Session Variables immediately (and not wait 'til they time out).

How (and on what event) can I do this? I looked at the JavaScript onUnload event, but that event fires everytime you leave the page...I need an event when the user clicks the 'X' in the upper right-hand corner to close the browser!

Oh - I need it in both IE & Netscape.

Thanks for any suggestions you have to offer!
 
They are destroyed as soon as the browser closes. You try coming back in with a new browser instance, a new session is started, meaning there is no record of the one you just closed - no cookie.

<bb/>
 
I have an expiration time set on my cookie, so even though I close the browser, the cookie still exists until the expiration time has been met.
 
I may be repeating GIGN, but the cookies and vars are deleted when the browser closes UNLESS you have a expiration date set. So in turn you need to get rid of that nasty expiration date and problem will be solved. provide tools to let people become their best.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top