473,386 Members | 1,773 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Session handling when user closes browser

I'm writing a .NET 2.0 app that needs to manage user sessions. We're using
SQL Server 2005 tables to hold sessions status fields in a table. The
problem is how to handle the situation where a user closes the browser
without logging out first. We're using our own authentication, not Windows.
We'd like to somehow log the user out and free up the user seat? There
doesn't seem to be a method in .net to capture the browser close event.

How is this kind of thing normally handled in .NET? Is there anything I can
do?

Thank you!!
May 21 '07 #1
4 1788
>How is this kind of thing normally handled in .NET? Is there anything I can
>do?
No really good way, due to the stateless nature of the web and your
lack of control over the browser. You can handle the onunload event on
the client and notify the server. But you have to keep in mind that
leaving a page or closing a window isn't necessarily the same as
leaving the application (the user may have multiple windows open etc).

Personally I'd rather rely on session timeout.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 21 '07 #2
Hello, actually this helps to know there's no good way to handle. We just
didn't want to overlook something that might be obvious or simple. Thanks for
your advice!
"Mattias Sjögren" wrote:
How is this kind of thing normally handled in .NET? Is there anything I can
do?

No really good way, due to the stateless nature of the web and your
lack of control over the browser. You can handle the onunload event on
the client and notify the server. But you have to keep in mind that
leaving a page or closing a window isn't necessarily the same as
leaving the application (the user may have multiple windows open etc).

Personally I'd rather rely on session timeout.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 21 '07 #3
Can you tell me if the session_end in global.asax will get triggered even if
the browser window is closed while the session is active? I don't think this
is the case but it's possible. Also, if we eventually use SQL Server for
state management, will session_end still be triggered?

Thanks!
"Mattias Sjögren" wrote:
How is this kind of thing normally handled in .NET? Is there anything I can
do?

No really good way, due to the stateless nature of the web and your
lack of control over the browser. You can handle the onunload event on
the client and notify the server. But you have to keep in mind that
leaving a page or closing a window isn't necessarily the same as
leaving the application (the user may have multiple windows open etc).

Personally I'd rather rely on session timeout.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 21 '07 #4
Upon thinking about this more, I'm wondering how I could use session-time out
as you suggested below in order to update the SQL database to log
end-of-session info like date/time of logout. If the user closes the browser,
doesn't the session just die, or is there a way to get control and do the
database update for that user?

Thanks!!

"Mattias Sjögren" wrote:
How is this kind of thing normally handled in .NET? Is there anything I can
do?

No really good way, due to the stateless nature of the web and your
lack of control over the browser. You can handle the onunload event on
the client and notify the server. But you have to keep in mind that
leaving a page or closing a window isn't necessarily the same as
leaving the application (the user may have multiple windows open etc).

Personally I'd rather rely on session timeout.
Mattias

--
Mattias Sjögren [C# MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
May 21 '07 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
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...
14
by: Darrin J Olson | last post by:
I am trying to end a session for a site without having to completely close the browser to end it. When I access the site and log in it works fine. If I log out and in with a different account...
4
by: Rafael Chemtob | last post by:
Hi, I'm using session cookies on my web app and it looks like the session is not being killed when the user closes the browser. We use a Global.asa file on our app. Do we have to explicitly...
2
by: Amit D.Shinde | last post by:
Hello Experts.. I need some help regarding cookies and session objects and also global.asa file I am creating one cookie when a user logs in on my website. The cookie stores the login name of...
11
by: David Lozzi | last post by:
Hello All, I am having an issue with thus far one computer on my client's web site. If the user loads the shopping cart and then closes all browser windows, then opens them back up, goes back to...
4
by: Chris | last post by:
When a request comes into a page on my ASP.net site and a session is not found, I want to detect whether the request is an initial request or if the user did have a session going that has now been...
5
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...
2
by: Paul W | last post by:
Using default session handling (ie. inproc and with cookies). I have a 'logout' button that returns the user to the login screen and does a session.abandon. HOWEVER, if they then log back in...
5
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...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.