How Do You Detecting Session Timeout?

C

Chris Newby

I realize that I can handle "SessionEnd" from global.asax ... but it appears
to me that this gets called without the context of a current web request. So
given the following scenario:

User logs in and session starts
User is inactive longer than the session timeout setting
Some thread, not associated with a request, detects the timeout and raises
Session_End()
The User comes back to the site presenting a timed-out session id
ASP.NET restarts the session (obviously without any data from the previous
session)

My question is, when the user returns with a timed-out session id, is there
a way for me to empirically determine that their session has timed-out? A
property that I am perhaps missing somewhere? I realize I can check their
session contents collection for a peice of data that would otherwise be
there, however this seems somewhat indirect to me and, in my particular
case, potentially not "complete" enough to make the determination.

Any thoughts are welcome,
TIA//
 
B

BillGatesFan

I believe the only way of knowing is by the Session_End event. You can
catch it there but I don't know what good that would do. The only other
suggestion is to start a timer when there session starts and do
something if there is no activity before it ends. There are examples of
this in this forum.
 
B

Bruce Barker

when user hits the site with an expired session cookie, a new session is
created. in the new session event, look for the old session cookie in the
request( currently ASP.NET_SessionId)

-- bruce (sqlwork.com)
 
C

Chris Newby

I considered that ... but it appeared that ASP.NET just renewed the old
session id ... are you sure about this?
 
J

Juan T. Llibre

If all client browser instances haven't been closed
the Session ID will be recycled.

If all client browser instances have been closed,
a new Session ID will be issued.
 

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

Members online

Forum statistics

Threads
473,792
Messages
2,569,639
Members
45,352
Latest member
SherriePet

Latest Threads

Top