468,765 Members | 979 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Session_End does not fire when user closes browser

I thought for sure Session End would fire when the user closes his browser,
but no luck. The only way I can get the event to fire is to run a
Session.Abandon, but is that really practicle? When a user is down they
will probably close out the browser or navigate somewhere else.

I want to keep a total count of users in an Application state variable but I
cannot count on the decrement code to run. What can I do to keep up with
Total Users in my app?

Many thanks,

Keith
Nov 18 '05 #1
4 9807
Session End fires when a session is abandoned or times out (default of
20 minutes). This is because the server has no way of knowing when the
browser has closed (stateless and all that jazz).

The drawback to all this is it makes getting an accurate count quite
difficult as you can't force a user to hit a logout button, you can't
reliably catch the browser closing event, and if you shorten the session
timeout too far you may end up with upset users whose session values got
cleared while they wrote up a sticky note to pickup the kids from school.

Also remember that each unique instance of a browser gets its own
session, so one user could open two instances of the website in two
browsers on their desktop (past experience says this happens more than
one might think). When this happens you loose some of the accuracy of
your count. If you are willing to go with the idea that the best you are
going to get is "close enough" then I'd say keep going with what you
have and accept that the numbers you are seeing are an approximation
over the life of a session timeout. Oh, and if you use some form of
logon you can get this a bit more accurate by keeping count of only the
unique logons within the timeout range.

Hope that helps in some manner.

Have A Better One!

John M Deal, MCP
Necessity Software

Keith-Earl wrote:
I thought for sure Session End would fire when the user closes his browser,
but no luck. The only way I can get the event to fire is to run a
Session.Abandon, but is that really practicle? When a user is down they
will probably close out the browser or navigate somewhere else.

I want to keep a total count of users in an Application state variable but I
cannot count on the decrement code to run. What can I do to keep up with
Total Users in my app?

Many thanks,

Keith

Nov 18 '05 #2
This is actually kind of by design. WWW is a stateless system. Users aren't
connected. They connect, get the info, disconnect. All these "counts" are
false in reality. Now, that said, the Session End will fire when they
timeout so you will still get a decent count but it may take a while for the
timeout to occur. A "logout" button will help as well, with the
Session.Abandon as you indicated but there is no 100% way to get the count
you are after because that number doesn't really exist in the first place...
Make sense?

--
Curt Christianson
Owner/Lead Developer, DF-Software
Site: http://www.Darkfalz.com
Blog: http://blog.Darkfalz.com
"Keith-Earl" <ke***********************@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP11.phx.gbl...
I thought for sure Session End would fire when the user closes his browser,
but no luck. The only way I can get the event to fire is to run a
Session.Abandon, but is that really practicle? When a user is down they
will probably close out the browser or navigate somewhere else.

I want to keep a total count of users in an Application state variable but
I cannot count on the decrement code to run. What can I do to keep up with
Total Users in my app?

Many thanks,

Keith

Nov 18 '05 #3
No. It fires when the session ends (by default 20mn later).

Patrice

--

"Keith-Earl" <ke***********************@hotmail.com> a écrit dans le message
de news:%2****************@TK2MSFTNGP11.phx.gbl...
I thought for sure Session End would fire when the user closes his browser, but no luck. The only way I can get the event to fire is to run a
Session.Abandon, but is that really practicle? When a user is down they
will probably close out the browser or navigate somewhere else.

I want to keep a total count of users in an Application state variable but I cannot count on the decrement code to run. What can I do to keep up with
Total Users in my app?

Many thanks,

Keith

Nov 18 '05 #4


"Keith-Earl" wrote:
I thought for sure Session End would fire when the user closes his browser,
but no luck. The only way I can get the event to fire is to run a
Session.Abandon, but is that really practicle? When a user is down they
will probably close out the browser or navigate somewhere else.

I want to keep a total count of users in an Application state variable but I
cannot count on the decrement code to run. What can I do to keep up with
Total Users in my app?

Many thanks,

Keith

Nov 18 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

5 posts views Thread by JezB | last post: by
3 posts views Thread by Guadala Harry | last post: by
3 posts views Thread by MattB | last post: by
1 post views Thread by Timo | last post: by
11 posts views Thread by OldProgrammer | last post: by
6 posts views Thread by Calvin Willman | last post: by
8 posts views Thread by Roger | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.