Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Session_End does not fire when user closes browser

Reply
Thread Tools

Session_End does not fire when user closes browser

 
 
Keith-Earl
Guest
Posts: n/a
 
      11-15-2004
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


 
Reply With Quote
 
 
 
 
John M Deal
Guest
Posts: n/a
 
      11-15-2004
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
>
>

 
Reply With Quote
 
 
 
 
Patrice
Guest
Posts: n/a
 
      11-15-2004
No. It fires when the session ends (by default 20mn later).

Patrice

--

"Keith-Earl" <(E-Mail Removed)> a écrit dans le message
de news:%(E-Mail Removed)...
> 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
>
>



 
Reply With Quote
 
Curt_C [MVP]
Guest
Posts: n/a
 
      11-15-2004
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" <(E-Mail Removed)> wrote in message
news:%(E-Mail Removed)...
>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
>



 
Reply With Quote
 
=?Utf-8?B?Q293Ym95IChHcmVnb3J5IEEuIEJlYW1lcikgLSBNVlA=?=
Guest
Posts: n/a
 
      11-15-2004


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

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session_End Event does not Fire. =?Utf-8?B?T2xkUHJvZ3JhbW1lcg==?= ASP .Net 5 09-22-2005 01:43 PM
How can I make sure that Session_End is called when the user closes the browser? Annie ASP .Net 6 09-14-2005 12:08 PM
does Session_End event fire when the worker process recycles? srivalli c via DotNetMonster.com ASP .Net 1 06-22-2005 10:24 PM
Session_End doesn't fire after uploading new code to live server Ben Fidge ASP .Net 3 10-27-2004 01:08 PM
session not being killed after user closes browser Rafael Chemtob ASP General 4 02-12-2004 05:58 PM



Advertisments