Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

Session variables stay when Firefox is closed, but not in IE

When I close my IE 6 browser and re-open and navigate to my ASP.Net website all of my session variables are null.
In Firefox 2 when I close the browser and re-open and navigate to my ASP.Net website all of the previous session variables are still there.

I want the session variables to be cleared when the user closes their Firefox 2 browser. The default options in Firefox 2 do not have this occur. Is there a way via code or web.config to make sure that these sessions variables (cookies on the client-side) get cleared whenever the browser is closed?
[568 byte] By [Billkamm] at [2007-11-11 10:12:54]
# 1 Re: Session variables stay when Firefox is closed, but not in IE
Not tested, but you could try clearing them in the Session_End() event in Global.asax.

You may have to add Global.asax to your app- it's one of the options when you add a new item to your web app.

Simply add code like

Session("Name of session variable") = ""

If it's a string...

HTH,

-Andrew
Andrew Cushen at 2007-11-11 23:12:01 >
# 2 Re: Session variables stay when Firefox is closed, but not in IE
The problem actually appears to be that if you have multiple Firefox windows open it won't clear the cookies until every window is closed. In IE it will clear the cookies for an individual browser window when it is closed.

I still need to find a workaround though :-/
Billkamm at 2007-11-11 23:13:01 >
# 3 Re: Session variables stay when Firefox is closed, but not in IE
I don't believe this behavior is specified in the standards, so the browser is free to handle it either way...

So it seems IE considers one window to be a session, whereas FireFox considers all open windows to be a session. Have you tried testing with Opera to see what it does?

And are those other FireFox windows open to a URL on your website, maybe through a popup window, or to random other sites? Did those windows ever have your site open in them during their lifetime? Or were they separate launches of the Firefox .EXE?

-Andrew
Andrew Cushen at 2007-11-11 23:14:06 >
# 4 Re: Session variables stay when Firefox is closed, but not in IE
I'm a little confused by your description. Are you referring to cookies (client-side) or session variables (server-side)?
pclement at 2007-11-11 23:15:12 >