Connecting Tech Pros Worldwide Forums | Help | Site Map

Global - Session End Event Problem

news.microsoft.com
Guest
 
Posts: n/a
#1: May 23 '06
We are logging many events on our application but cant seem to discover how
to determine who the user was in the session end event, as any session
storage seems to have disapeared at the point at which the event fires.

In essence, I want to log when a users session expires.

Any inspiration would be appreciated.



Altaf Al-Amin Najwani
Guest
 
Posts: n/a
#2: May 23 '06

re: Global - Session End Event Problem


The session end event is fired when the user is provided with the Signout
button and you call session session.Abandon method. But if the users are
closing the window directly by clicking X sign then this event will not be
fired . As browser is on client side and session is on server side. May be
due to this reason you are unable to log session end.

"news.microsoft.com" wrote:
[color=blue]
> We are logging many events on our application but cant seem to discover how
> to determine who the user was in the session end event, as any session
> storage seems to have disapeared at the point at which the event fires.
>
> In essence, I want to log when a users session expires.
>
> Any inspiration would be appreciated.
>
>
>[/color]
news.microsoft.com
Guest
 
Posts: n/a
#3: May 23 '06

re: Global - Session End Event Problem


This is not true.

Set your timeout to one minute, and breakpoint inside the session_end event.
It will fire regardless of any user interaction.

The problem is that the session variables are no longer there apparently, so
I need to determin who's session was timed out.

As far as I can tell, its a poor show if you cant do this.



"Altaf Al-Amin Najwani" <altaf.alamin@gmail.com> wrote in message
news:0CF22F46-6939-4489-B29F-A8AC0D912737@microsoft.com...[color=blue]
> The session end event is fired when the user is provided with the Signout
> button and you call session session.Abandon method. But if the users are
> closing the window directly by clicking X sign then this event will not be
> fired . As browser is on client side and session is on server side. May be
> due to this reason you are unable to log session end.
>
> "news.microsoft.com" wrote:
>[color=green]
>> We are logging many events on our application but cant seem to discover
>> how
>> to determine who the user was in the session end event, as any session
>> storage seems to have disapeared at the point at which the event fires.
>>
>> In essence, I want to log when a users session expires.
>>
>> Any inspiration would be appreciated.
>>
>>
>>[/color][/color]


Altaf Al-Amin Najwani
Guest
 
Posts: n/a
#4: May 23 '06

re: Global - Session End Event Problem


I know this. But What i mean is if you provide signout option then you can
track when user is in session_end event. I had similar problem and i solved
in this way. I write code in my Page Base in which i was checking session
cookie coming with request against the session.isnew and then call my
function which logs that session is expired for particular sessionid. When
signing in .. I m keeping hashtable of userid and sessionid, so in this
manner i know for which user session_end is fired. See code below to check
for session timeout

if (Context.Session != null)
{
if (Context.Session.IsNewSession)
{
string sCookieHeader = Page.Request.Headers["Cookie"];
if ((null != sCookieHeader) &&
(sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
if (Page.Request.IsAuthenticated)
{
MyFunctionToLog();
}
}
}

}



"news.microsoft.com" wrote:
[color=blue]
> This is not true.
>
> Set your timeout to one minute, and breakpoint inside the session_end event.
> It will fire regardless of any user interaction.
>
> The problem is that the session variables are no longer there apparently, so
> I need to determin who's session was timed out.
>
> As far as I can tell, its a poor show if you cant do this.
>
>
>
> "Altaf Al-Amin Najwani" <altaf.alamin@gmail.com> wrote in message
> news:0CF22F46-6939-4489-B29F-A8AC0D912737@microsoft.com...[color=green]
> > The session end event is fired when the user is provided with the Signout
> > button and you call session session.Abandon method. But if the users are
> > closing the window directly by clicking X sign then this event will not be
> > fired . As browser is on client side and session is on server side. May be
> > due to this reason you are unable to log session end.
> >
> > "news.microsoft.com" wrote:
> >[color=darkred]
> >> We are logging many events on our application but cant seem to discover
> >> how
> >> to determine who the user was in the session end event, as any session
> >> storage seems to have disapeared at the point at which the event fires.
> >>
> >> In essence, I want to log when a users session expires.
> >>
> >> Any inspiration would be appreciated.
> >>
> >>
> >>[/color][/color]
>
>
>[/color]
Altaf Al-Amin Najwani
Guest
 
Posts: n/a
#5: May 23 '06

re: Global - Session End Event Problem


One more easy approach,
1)Create Global Hashtable
2)In session Start save Identity of user based on session id in hashtable
like this
list.Add(Me.Session.SessionID, User.Identity.Name)
3)In Session end get the Identity of the user whose session is expired by
using this code
list.Item(Me.Session.SessionID)

I have already implemented it , and its working

"Altaf Al-Amin Najwani" wrote:
[color=blue]
> I know this. But What i mean is if you provide signout option then you can
> track when user is in session_end event. I had similar problem and i solved
> in this way. I write code in my Page Base in which i was checking session
> cookie coming with request against the session.isnew and then call my
> function which logs that session is expired for particular sessionid. When
> signing in .. I m keeping hashtable of userid and sessionid, so in this
> manner i know for which user session_end is fired. See code below to check
> for session timeout
>
> if (Context.Session != null)
> {
> if (Context.Session.IsNewSession)
> {
> string sCookieHeader = Page.Request.Headers["Cookie"];
> if ((null != sCookieHeader) &&
> (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
> {
> if (Page.Request.IsAuthenticated)
> {
> MyFunctionToLog();
> }
> }
> }
>
> }
>
>
>
> "news.microsoft.com" wrote:
>[color=green]
> > This is not true.
> >
> > Set your timeout to one minute, and breakpoint inside the session_end event.
> > It will fire regardless of any user interaction.
> >
> > The problem is that the session variables are no longer there apparently, so
> > I need to determin who's session was timed out.
> >
> > As far as I can tell, its a poor show if you cant do this.
> >
> >
> >
> > "Altaf Al-Amin Najwani" <altaf.alamin@gmail.com> wrote in message
> > news:0CF22F46-6939-4489-B29F-A8AC0D912737@microsoft.com...[color=darkred]
> > > The session end event is fired when the user is provided with the Signout
> > > button and you call session session.Abandon method. But if the users are
> > > closing the window directly by clicking X sign then this event will not be
> > > fired . As browser is on client side and session is on server side. May be
> > > due to this reason you are unable to log session end.
> > >
> > > "news.microsoft.com" wrote:
> > >
> > >> We are logging many events on our application but cant seem to discover
> > >> how
> > >> to determine who the user was in the session end event, as any session
> > >> storage seems to have disapeared at the point at which the event fires.
> > >>
> > >> In essence, I want to log when a users session expires.
> > >>
> > >> Any inspiration would be appreciated.
> > >>
> > >>
> > >>[/color]
> >
> >
> >[/color][/color]
news.microsoft.com
Guest
 
Posts: n/a
#6: May 23 '06

re: Global - Session End Event Problem


Thanks, I found that the session information is active still, so I pass the
session reference to my logging and it all works.


"Altaf Al-Amin Najwani" <altaf.alamin@gmail.com> wrote in message
news:7F4A94EB-55B2-4BBB-8EA9-AFA805E7B975@microsoft.com...[color=blue]
> One more easy approach,
> 1)Create Global Hashtable
> 2)In session Start save Identity of user based on session id in hashtable
> like this
> list.Add(Me.Session.SessionID, User.Identity.Name)
> 3)In Session end get the Identity of the user whose session is expired by
> using this code
> list.Item(Me.Session.SessionID)
>
> I have already implemented it , and its working
>
> "Altaf Al-Amin Najwani" wrote:
>[color=green]
>> I know this. But What i mean is if you provide signout option then you
>> can
>> track when user is in session_end event. I had similar problem and i
>> solved
>> in this way. I write code in my Page Base in which i was checking session
>> cookie coming with request against the session.isnew and then call my
>> function which logs that session is expired for particular sessionid.
>> When
>> signing in .. I m keeping hashtable of userid and sessionid, so in this
>> manner i know for which user session_end is fired. See code below to
>> check
>> for session timeout
>>
>> if (Context.Session != null)
>> {
>> if (Context.Session.IsNewSession)
>> {
>> string sCookieHeader =
>> Page.Request.Headers["Cookie"];
>> if ((null != sCookieHeader) &&
>> (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
>> {
>> if (Page.Request.IsAuthenticated)
>> {
>> MyFunctionToLog();
>> }
>> }
>> }
>>
>> }
>>
>>
>>
>> "news.microsoft.com" wrote:
>>[color=darkred]
>> > This is not true.
>> >
>> > Set your timeout to one minute, and breakpoint inside the session_end
>> > event.
>> > It will fire regardless of any user interaction.
>> >
>> > The problem is that the session variables are no longer there
>> > apparently, so
>> > I need to determin who's session was timed out.
>> >
>> > As far as I can tell, its a poor show if you cant do this.
>> >
>> >
>> >
>> > "Altaf Al-Amin Najwani" <altaf.alamin@gmail.com> wrote in message
>> > news:0CF22F46-6939-4489-B29F-A8AC0D912737@microsoft.com...
>> > > The session end event is fired when the user is provided with the
>> > > Signout
>> > > button and you call session session.Abandon method. But if the users
>> > > are
>> > > closing the window directly by clicking X sign then this event will
>> > > not be
>> > > fired . As browser is on client side and session is on server side.
>> > > May be
>> > > due to this reason you are unable to log session end.
>> > >
>> > > "news.microsoft.com" wrote:
>> > >
>> > >> We are logging many events on our application but cant seem to
>> > >> discover
>> > >> how
>> > >> to determine who the user was in the session end event, as any
>> > >> session
>> > >> storage seems to have disapeared at the point at which the event
>> > >> fires.
>> > >>
>> > >> In essence, I want to log when a users session expires.
>> > >>
>> > >> Any inspiration would be appreciated.
>> > >>
>> > >>
>> > >>
>> >
>> >
>> >[/color][/color][/color]


Closed Thread