Sunday, October 30, 2011

How to check SessionTimeout in ASP.NET

The following code is useful to check Session Timeout.

protected bool SessionTimeout()

{

bool timeOut = false;

if (Context.Session != null)

{

if (Context.Session.IsNewSession)

{

string sCookieHeader = Page.Request.Headers["Cookie"];

if ((null != sCookieHeader) && (sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))

{

timeOut = true;

}

}

}

return timeOut;


No comments:

Post a Comment