|
-
Nov 4th, 2003, 03:04 PM
#1
Thread Starter
Hyperactive Member
Session_End not working?
Does the Session_End event fire when a browser is closed? I am using Session_Start and Session_End to add and subtract from a counter. When a session starts it works fine. When a user closes the browser, the subtraction doesnt work. I am using the global.asax file to increment and decrement the count. Just that the End doesnt work. Any ideas?
..::[ kleptos]::..
- Database Administrator (MSSQL 2000)
- Application Developer (C#)
- Web Developer (ASP.NET)

-
Nov 4th, 2003, 03:25 PM
#2
PowerPoster
Session events (especially Session_OnEnd) have been known to be very flaky..
-
Nov 4th, 2003, 04:19 PM
#3
Thread Starter
Hyperactive Member
Thats what i was afraid of. Thanks!
..::[ kleptos]::..
- Database Administrator (MSSQL 2000)
- Application Developer (C#)
- Web Developer (ASP.NET)

-
Nov 4th, 2003, 09:49 PM
#4
Hyperactive Member
Flaky is a bit general. A session depends on a timeout value specified in the web.config or IIS. I think it defaults to 20 minutes. So the session will end 20 minutes after the user logs in/opens the browser regardless of when they close it.
This is web server based technology we are talking about. I don't know any web server technology that can tell when a user closes their browser.
-
Nov 4th, 2003, 10:45 PM
#5
PowerPoster
Originally posted by Musician
Flaky is a bit general.
There are countless articles that say do not depend on the Session_OnEnd() event firing consistently.
http://www.eggheadcafe.com/articles/20030416.asp
http://www.mail-archive.com/bdotnet@.../msg02003.html
etc..
Last edited by Lethal; Nov 4th, 2003 at 10:50 PM.
-
Nov 5th, 2003, 01:47 PM
#6
Hyperactive Member
I'm not disputing the unrealiability of session_onend. It's just important to be clear on why this is the case. Because of the nature of a session itself not due to any flaky design in the implementation of an event.
-
Nov 5th, 2003, 02:25 PM
#7
PowerPoster
I agree, because HTTP is a stateless protocol, the web server has no way of detecting when a user leaves a Web site. So, when a certain period of time has elapsed without the user requesting a page, the session data is removed and the session is killed. This is all nice an dandy, but when I say 'flaky', I am refering to the Session_End() event not *always* firing. There are numerous articles explaining workarounds because of this.
-
Nov 6th, 2003, 12:44 AM
#8
PowerPoster
Ya, I read those links about the session_end not working. I haven't tried to use it yet, but was looking into it to show who is currently browsing my forums. After seeing the default timeout, there is no way to accurately tell if the user is gone or not. I could adjust the timeout of the session, but it will affect other parts.
Any suggestions on how to do this? Basically the same functionality that is on these forums to show who is browsing what forums.
-
Nov 6th, 2003, 10:10 AM
#9
PowerPoster
Hellswraith,
I'll shoot you the code I use in my forums. What email do you want me to send it 2.
-
Nov 6th, 2003, 11:10 AM
#10
It is not that Session onend in flaky. The fact is, a web browser doesnt send a signal back to the server when it is closed. A server has no way of knowing you closed your browser.
-
Nov 6th, 2003, 02:22 PM
#11
Hyperactive Member
I would imagine a non-persistent cookie is the way to go for what you want to do.
-
Nov 6th, 2003, 05:08 PM
#12
PowerPoster
Originally posted by Cander
It is not that Session onend in flaky. The fact is, a web browser doesnt send a signal back to the server when it is closed. A server has no way of knowing you closed your browser.
Agreed, thats what I said in my second post to clear things up.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|