Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > How to access session variables in Session_End in global.asax?

Reply
Thread Tools

How to access session variables in Session_End in global.asax?

 
 
Kim Bach Petersen
Guest
Posts: n/a
 
      11-01-2004
I would like to record user behavior data stored in session variables.

Since the data is modified throughout each session it seemed obvious to
store the data when the session terminates - using Session_End in
global.asax.

Problem is, apparently the session-object terminating cannot be accessed
from Session_End in global.asax!?

What's the meaning of Session_End if you don't know which session is
endning?

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Store data from
' System.Web.HttpContext.Current.Session("behavior")
' in database
End Sub

Kim )


 
Reply With Quote
 
 
 
 
Kevin Spencer
Guest
Posts: n/a
 
      11-01-2004
> Problem is, apparently the session-object terminating cannot be accessed
> from Session_End in global.asax!?
>
> What's the meaning of Session_End if you don't know which session is
> endning?


What's the meaning of a brake pedal on a car if every car on the road has
one? The answer is, the brake pedal in the car you're driving is yours.
There is one Session per client. When Session_End is called, it is called
for that client. It is the brake pedal on that client's car. It can't
operate on any other client, any more than pressing your brake pedal can
slow down anyone else's car but yours.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Kim Bach Petersen" <> wrote in message
news:...
> I would like to record user behavior data stored in session variables.
>
> Since the data is modified throughout each session it seemed obvious to
> store the data when the session terminates - using Session_End in
> global.asax.
>
> Problem is, apparently the session-object terminating cannot be accessed
> from Session_End in global.asax!?
>
> What's the meaning of Session_End if you don't know which session is
> endning?
>
> Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
> ' Store data from
> ' System.Web.HttpContext.Current.Session("behavior")
> ' in database
> End Sub
>
> Kim )
>
>



 
Reply With Quote
 
 
 
 
Kim Bach Petersen
Guest
Posts: n/a
 
      11-01-2004
Kevin Spencer skrev:

>> Problem is, apparently the session-object terminating cannot be
>> accessed from Session_End in global.asax!?
>>
>> What's the meaning of Session_End if you don't know which session is
>> endning?

>
> What's the meaning of a brake pedal on a car if every car on the road
> has one? The answer is, the brake pedal in the car you're driving is
> yours. There is one Session per client. When Session_End is called,
> it is called for that client. It is the brake pedal on that client's
> car. It can't operate on any other client, any more than pressing
> your brake pedal can slow down anyone else's car but yours.


Clear enough, I got the concept of sessions, and of course Session_End is
called for an instance when it ends.

Still, can I access the session object from Session_End - and if yes, how?

I would like to acces session-object variables such as

System.Web.HttpContext.Current.Session.SessionId
System.Web.HttpContext.Current.Session("behavior")

but apparently I can't within Session_End?

Kim )


 
Reply With Quote
 
bruce barker
Guest
Posts: n/a
 
      11-02-2004
there is no valid System.Web.HttpContext.Current at session end because
there is no web request. just use the Session property of the global.asax



"Kim Bach Petersen" <> wrote in message
news:...
> I would like to record user behavior data stored in session variables.
>
> Since the data is modified throughout each session it seemed obvious to
> store the data when the session terminates - using Session_End in
> global.asax.
>
> Problem is, apparently the session-object terminating cannot be accessed
> from Session_End in global.asax!?
>
> What's the meaning of Session_End if you don't know which session is
> endning?
>
> Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
> ' Store data from
> ' System.Web.HttpContext.Current.Session("behavior")
> ' in database
> End Sub
>
> Kim )
>
>



 
Reply With Quote
 
Kevin Spencer
Guest
Posts: n/a
 
      11-02-2004
You can refer to the current Session as Session or this.Session. Session is
a member of the HttpApplication class from which the Global class is
derived.

--
HTH,
Kevin Spencer
..Net Developer
Microsoft MVP
I get paid good money to
solve puzzles for a living

"Kim Bach Petersen" <> wrote in message
news:#...
> Kevin Spencer skrev:
>
> >> Problem is, apparently the session-object terminating cannot be
> >> accessed from Session_End in global.asax!?
> >>
> >> What's the meaning of Session_End if you don't know which session is
> >> endning?

> >
> > What's the meaning of a brake pedal on a car if every car on the road
> > has one? The answer is, the brake pedal in the car you're driving is
> > yours. There is one Session per client. When Session_End is called,
> > it is called for that client. It is the brake pedal on that client's
> > car. It can't operate on any other client, any more than pressing
> > your brake pedal can slow down anyone else's car but yours.

>
> Clear enough, I got the concept of sessions, and of course Session_End is
> called for an instance when it ends.
>
> Still, can I access the session object from Session_End - and if yes, how?
>
> I would like to acces session-object variables such as
>
> System.Web.HttpContext.Current.Session.SessionId
> System.Web.HttpContext.Current.Session("behavior")
>
> but apparently I can't within Session_End?
>
> Kim )
>
>



 
Reply With Quote
 
JamesJM JamesJM is offline
Junior Member
Join Date: Aug 2011
Posts: 1
 
      08-03-2011
Before you call session.Abandon save any data that you will want to access in
Session_End in local variables then after session.Abandon you can declare session variables with the local variable values and you will be able to access them in Session_End

JamesJM
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Session_End and variables? Lucas Tam ASP .Net 2 03-01-2005 10:04 PM
Changing the value of Session.Timeout triggers a call to Global.asax.Session_End function at end of request Samuel Stanojevic ASP .Net 1 09-15-2004 03:35 AM
detecting session timeout in Session_End jules ASP .Net 0 04-14-2004 07:48 PM
Session_End and SqlServer Session Mode karahan celikel ASP .Net 8 02-17-2004 08:34 PM
Session lasting too long -- Session_End event firing way late !! ?? Steve M ASP .Net 5 07-31-2003 09:44 AM



Advertisments