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