473,513 Members | 2,307 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 10101
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
3452
by: JezB | last post by:
Why is my Session_End event in global.asax never firing ? I've tried fiddling with the timeouts but still nothing. Ideally I want to do some processing whenever someone leaves my web application...
3
566
by: Guadala Harry | last post by:
Just wondering if Session_End *always fires* for every Session. I know that IIS times out sessions after a default 20 min (unless changed) and there's no way to know when a user actually closed a...
3
1597
by: MattB | last post by:
Hi. I have a couple of questions regarding the Session_End event. I have some clean-up code in this event and it does fire when the session times out, which is good. I also want to have this (or...
1
4582
by: Timo | last post by:
A few questions relating to sessions ending. 1. What happens to the session when a user closes the browser? Does the session remain alive until it times out? 2. In the Session_End...
6
2091
by: Annie | last post by:
Hi guys, I just want to do some clean up in the Session_End at Global.aspx. However, if the user closes the browser window that event is not fired. how can I call explicity protected void...
11
2804
by: OldProgrammer | last post by:
All the documentation and discussion I have read indicate that the Session_End is not supposed to fire unless you are in "inProc" Session state mode, and then only on Session Timeout or at Session...
6
2133
by: Calvin Willman | last post by:
ASP.NET 2.0, Visual Web Developer Express I've written a web app, which creates a Gif to display on the page. I name it .gif, and only want it to last as long as the session, so I've included ...
8
5764
by: Roger | last post by:
When I call the session.abandon() method, it calls the session_end event. When a user closes the browser or clicks the log off button, I can dispose of objects and abandon the session cleaning....
5
2752
by: Ron J | last post by:
I would like to keep track of users when they are 'on'. On Session_Start I can write a DB record about them, but there does not seem to be session variable information during the Session_end event...
0
7265
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
7171
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7539
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5692
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5095
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4751
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3240
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3228
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
807
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.