Showing posts with label Session. Show all posts
Showing posts with label Session. Show all posts

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;


How to fix missing session in iframe using ASP.NET

When you face missing session in iframe, it can solve with the following code:

Response.AppendHeader("P3P", "CP=\"CAO PSA OUR\"");

You put the above code in Page Load event. That's it.