how to determine Session is Alive or not
-
Hi All. Iam new to asp.net. I want to know how can we determine that session is alive or expired. Actually I created a session Session["LoogeIn"] when user logs In, and I used this session across the application.But when saving or updating records , it gives Error if Session is expired ( I am using Session when savinf or updating records.) So I am confused how can I determine that whether Session is expired or not. And In case of Expire I want to redirect the page to login page, so session can start again. Thanks in advance. bye
Bajrang Singh Using .net 2.0 (VS2005)
-
Hi All. Iam new to asp.net. I want to know how can we determine that session is alive or expired. Actually I created a session Session["LoogeIn"] when user logs In, and I used this session across the application.But when saving or updating records , it gives Error if Session is expired ( I am using Session when savinf or updating records.) So I am confused how can I determine that whether Session is expired or not. And In case of Expire I want to redirect the page to login page, so session can start again. Thanks in advance. bye
Bajrang Singh Using .net 2.0 (VS2005)
If the session has expired, the user will get a new Session object, where the Items collection is empty. When you try to read a value from the empty collection you will get a null value, so you just have to check for that.
--- single minded; short sighted; long gone;
-
Hi All. Iam new to asp.net. I want to know how can we determine that session is alive or expired. Actually I created a session Session["LoogeIn"] when user logs In, and I used this session across the application.But when saving or updating records , it gives Error if Session is expired ( I am using Session when savinf or updating records.) So I am confused how can I determine that whether Session is expired or not. And In case of Expire I want to redirect the page to login page, so session can start again. Thanks in advance. bye
Bajrang Singh Using .net 2.0 (VS2005)
Hey you have to check the sessions if they are empty during the page load event. write the below code on page load event If session("YOUR_SESSION_VARIABLE") = "" then response.redirect("LOGIN_PAGE_URL") End If Try this out..... Regards, Kaps
-
Hey you have to check the sessions if they are empty during the page load event. write the below code on page load event If session("YOUR_SESSION_VARIABLE") = "" then response.redirect("LOGIN_PAGE_URL") End If Try this out..... Regards, Kaps
You can also use the global.asax and use the session time out method. With that you can redirect the user to a login page or a 'default' page for session timeout information. e.g., // this is inside the global.asax void Session_End(object sender, EventArgs e) { // Code that runs when a session ends. // Note: The Session_End event is raised only when the sessionstate mode // is set to InProc in the Web.config file. If session mode is set to StateServer // or SQLServer, the event is not raised Server.Transfer("login.aspx"); } why Server.Transfer? here is more info on the do's and dont's http://www.developer.com/net/asp/article.php/3299641[^]