Global - Session End Event Problem

N

news.microsoft.com

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.
 
G

Guest

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.
 
N

news.microsoft.com

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.
 
G

Guest

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();
}
}
}

}
 
G

Guest

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 said:
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 said:
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.
 
N

news.microsoft.com

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 said:
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 said:
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 said:
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.



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.

:

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.
 

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,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top