Session_End questions

M

MattB

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 similar) code fire when the session ends
prematurely, like when the browser window is closed or Session.Clear is
called. It appears that does not happen, but is there any way I can
force it or is there a different event that would fire in these cases?

Also, in my Session_End event, when this even fires, it it just before
the session ends or just after? I'd like to be able to access some
information I have in session state but I don't know if I should expect
it to be there at that time or not.

Thanks!

Matt
 
P

Patrice

No, the session doesn't end when the browser close. It ends whan ther is no
news from someone during a period of time that is 20 mn by default.

IMO you meant Session.Abandon that should work here. (and not Session.Clear)

For the window, you could use a trick just as calling a server side script
when the window closes that would call Session.Abandon.

Depending on what you want to do you can sometimes just separate this from
the end of the session and have for example a cleanup task running as a SQL
job...

Patrice
 
H

Hans Kesting

MattB said:
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 similar) code fire when the session ends
prematurely, like when the browser window is closed or Session.Clear
is called. It appears that does not happen, but is there any way I can
force it or is there a different event that would fire in these cases?

"browser close" does *not* cause the session to end! The session will
remain "alive" a further 20 minutes (default).
Instead of Session.Clear you could try to call Session.Abandon, this
should cause Session_End to be called. Clear just removes everything,
it doen't "end" the session, Abandon does.
Also, in my Session_End event, when this even fires, it it just before
the session ends or just after? I'd like to be able to access some
information I have in session state but I don't know if I should
expect it to be there at that time or not.

You can still access the session vars.
 
M

MattB

Hans said:
"browser close" does *not* cause the session to end! The session will
remain "alive" a further 20 minutes (default).
Instead of Session.Clear you could try to call Session.Abandon, this
should cause Session_End to be called. Clear just removes everything,
it doen't "end" the session, Abandon does.




You can still access the session vars.

Great. Thanks to you both!

Matt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Session_End 4
Session_Start/Session_End 3
global.aspx and session_end event 8
Session_End 3
Session_End 2
Session_End 14
session_end 4
Session_End() 1

Members online

Forum statistics

Threads
473,780
Messages
2,569,609
Members
45,254
Latest member
Top Crypto TwitterChannel

Latest Threads

Top