Session handling when user closes browser

G

Guest

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!!
 
M

Mattias Sjögren

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

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
 
G

Guest

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!
 
G

Guest

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!
 
G

Guest

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!!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top