Session_End

N

news.microsoft.com

I am reposting this because the person who replied to my original post did
not understand me. Please dont post a reply unless you 'absolutley ' know
what I am talking about and have a solution or an absolute reason why there
is no solution.

I want to log when a user logs off, so I wanted to use the session_end
event. This 'Does Fire' when the session expiry ends for the current
session. However, this event seems to fire 'After the session has ended' and
not just before it expired and hence, there seems to be no way to determine
who's session is ending.

I may be wrong in my assertion, if I am please correct me , give me a
workaround or simply explain why I cant do what I want to here.

Remember, if you dont know, please dont reply

Many Thanks
 
K

Kevin Spencer

HTTP is stateless. Once a request for a page is received by the server, the
request is handled and then forgotten. There is no persistent connection
between the server and the client. Session is memory on the server. It is
identified with a client application (such as a browser instance) by passing
data back and forth to and from the client with each Request/Response. By
default this happens using a Session cookie It can also be passed via
QueryString.

In any case, the first client visit to a web app initiates a Session on the
server, and the Session Cookie is passed to the client, so that the client
can re-link to his/her Session with each successive Request.

Since there is no such thing as a notification that the client is finishes,
in order to preserve memory on the server, there must be a mechanism for
de-allocation unused Session memory. This is done by means of a timeout that
is re-set with each successive Request from the same client. If no Requests
are made within the timeout period, the Session expires, and the next
request from the same client will initiate a new Session.

Therefore, there is only one way to know when a Session ends: when it times
out.

--
HTH,

Kevin Spencer
Microsoft MVP
Professional Numbskull

The man who questions opinions is wise.
The man who quarrels with facts is a fool.
 
N

news.microsoft.com

Kevin,

Thanks for your reply.

I found that I can still access the Session Valiables during the session_end
event. From this event I call a public shared member of my log class, I just
need to know how to find Session from this as there is no httpcontext during
this event. Can I find the session somethow from the current thread, or is
there another way ?

Cheers
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Pass it along in the method call. Either pass along a reference to the
Session object, or pass along the values of the session variables.
 
N

news.microsoft.com

Yeah, thats what I did in the end.



Göran Andersson said:
Pass it along in the method call. Either pass along a reference to the
Session object, or pass along the values of the session variables.
 

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,995
Messages
2,570,225
Members
46,815
Latest member
treekmostly22

Latest Threads

Top