473,513 Members | 2,359 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Kill Session Variables When User Closes Browser Window

19 New Member
Hi Everyone,

I have a .Net 2.0 C# web application that has important information stored in Sessions that needs to be deleted when the user closes the browser. I know of three ways a user can close their browser:
  1. Presses "X" button in top right of browser
  2. Presses Alt-F4
  3. From browser menu selects File -> Close
With javascript I am able to detect that the user presses the X button. Since Javascript is client side and ASP.Net is server side, I can't find a way to kill the sessions through javascript.

Are there any .Net methods for detecting the closing of the browser window so that I can do a call to "Session.Abandon()"? The method must be cross-browser compatible for at least IE6, IE7 and Firefox.

Thanks.
Mar 6 '08 #1
3 4216
Plater
7,872 Recognized Expert Expert
If the browser is closed, the session ID it had is lost, so they cannot get it back from your server.
All Session data itself is stored on the server, and normal behavior is to automatically flush it out after 20mins of inactivity by the user.

So I am not sure what the point of knowing when they close their browser is, as they cannot re-open their browser and get the same session back.
Mar 6 '08 #2
spoonybard
19 New Member
We have a website that the user goes to. On the page are several links to another one of our websites. Those links pop up the other website in a new window. If the person closes the new window and then clicks a link on the original page, when the new window opens, the original session data is still being held onto.
Mar 6 '08 #3
Plater
7,872 Recognized Expert Expert
Because the browser was never closed.
Closing "popup" child windows does not count as leaving the website.
If you are using javascript to open the windows, create an object for the window and then keep checking for when it goes to null(or if a property changes, would have to check the javascript DOM on window objects) which would be when the child window gets closed.
That might be more what you are after.
Mar 6 '08 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

9
3629
by: Pack Fan | last post by:
I've noticed that session variables will persist on Mac IE even after all browser windows have been closed. One must quit the program to clear the session variables. This presents a security risk...
1
7951
by: Vetrivel | last post by:
Application architecture : Develop interface between two existing systems, a. Enterprise CRM system b. Web based intranet system. Environment : Intranet Server : IIS and ASP. Script :...
3
7108
by: JezB | last post by:
I want to clear some specific Session variables when the user closes a page. On my page I have a "return to ..." button which navigates back to the parent page from which it was invoked - under the...
5
9093
by: news.microsoft.com | last post by:
Hi everyone, I need some help (may be in the form of some sample code) for the subject question. I have an ASP.NET/C# application. I need to do quite a few tasks when the session ends. I...
5
548
by: Sean | last post by:
Problem with sessions I have created an application without concern for sessions. As it turns out I think that might be my undoing. What I have: I have an online quiz. I don’t need to know...
18
3402
by: BillE | last post by:
When a user opens a new IE browser window using File-New-Window the integrity of an application which relies on session state is COMPLETELY undermined. Anyone who overlooks the fact that...
26
3579
by: BillE | last post by:
Some ASP.NET applications use Session Variables extensively to maintain state. These should be re-written to use viewstate, hidden fields, querystring, etc. instead. This is because if a user...
12
3810
by: MrHelpMe | last post by:
Hello again all, I've finished my whole application and now I don't like the whole session variables that I am using. I have a form, user fills in info clicks submit and using CDOSYSMail an...
9
1718
by: Robbe Morris - [MVP] C# | last post by:
For reasons I won't get into here, I'd be curious if anyone has tried to write an ASP.NET 2.0 site that could restrict the number of active sessions before disabling the application. By disable,...
0
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7388
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7111
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
1605
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
461
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.