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 gkittelson 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!
 
Hey Linda,

So far, we have found nothing that will trigger when the browser closes. Further, since javascript works off the client ans asp.net works off the server, I'm not sure if one would be able to communicate with the other (and JScript.NET is going to be a server side language, according to a microsoft presenter, so thats out too).

However, this may not be an issue.

.NET has its own garbage collection built into the framework. Periodically, it will go through and check to see if any objects currently live are actually being used. If not, it gets rid of them. So that clears up your session problem. As far as the cookies go, I never use them so I'm definately not an expert. There may be a javascript code that can fire on browser end which will delete it though; definately worth a try (in my head, the logic makes sense: client code can detect a browser closing...sounds right).

Jack
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top