Possible Duplicate:
How to Check whether Session is Expired or not in asp.net
What is the best way for a page to detect if a session has timed out in the code behind? I found the below code in a blog (http://mattslay.com/detecting-session-timeout-in-asp-net/). Is is ok or is there a better way?
if (Context.Session != null && Context.Session.IsNewSession)
{
string cookieHeader = Page.Request.Headers["Cookie"];
if ((null != cookieHeader) && (cookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
return true; // timeout occured
else
return false;
}