Answered by:
On Session_End Event SessionId is null...

Question
-
User-982924510 posted
I catch Session_End event and call a function
on that function i need sessionid param but it is null...
myfunc is like this
public static void MyLogout()
{
string mysessionid = HttpContext.Current.Session.SessionID.ToString() ;
myuserid = HttpContext.Current.Session["Myuser"].ToString();// do something here
}
how can i know the time outed session's id ?..
fer
Tuesday, June 7, 2011 8:00 PM
Answers
-
User-29804325 posted
Hi,
catch Session_End event and call a function
on that function i need sessionid param but it is null...
Instead using the HttpContext.Current.Session.SessionID. You should use Application.Session.SessionID in Session_End event.
Because in this period, HttpContext.Current is null, there's no request and response from the user.
void Session_End(object sender, EventArgs e) { string sessionId = this.Session.SessionID; //your code... }
Hope this can help you.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 13, 2011 9:41 PM
All replies
-
User1064403333 posted
Session variables are only available during the session. Not after.
Once the Session_End event has fired (default is 20 minutes), then any session variable will be unavailble i.e. Null.
What are you trying to do when the session has timed out?
Tuesday, June 7, 2011 9:31 PM -
User-982924510 posted
i am logging the users and prevent to open two sessions from different places at the same time.
when user doesn't logged out for 20 min it gets sessien_end. after that i want to clear the log rec.
i have to know some session params and sessionid to finish recording.
Wednesday, June 8, 2011 3:01 AM -
User1064403333 posted
i am logging the users and prevent to open two sessions from different places at the same time.Rather than looking at the log out or session end, you may want to check the login and session start.
When a user logs in, you could record UserName, IP address, datetime of login
Then, when another person tries to login from a different location with the same UserName, you can check your log table, compare, and decide if you want to allow access or not.
Wednesday, June 8, 2011 3:35 AM -
User-29804325 posted
Hi,
catch Session_End event and call a function
on that function i need sessionid param but it is null...
Instead using the HttpContext.Current.Session.SessionID. You should use Application.Session.SessionID in Session_End event.
Because in this period, HttpContext.Current is null, there's no request and response from the user.
void Session_End(object sender, EventArgs e) { string sessionId = this.Session.SessionID; //your code... }
Hope this can help you.
- Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
Monday, June 13, 2011 9:41 PM -
User-982924510 posted
Thanks
yes it helped...
Tuesday, June 14, 2011 3:35 AM