I have this code:
Its in the baseForm, which every page inherits. The problem is that Session.IsNewSession is always false for me.
I was thinking, an easier way perhaps (I'm new to sessions), is to set a session timeout once at the start. And then check if a session that I set at the start IsNull... would that work? If the session variable is null then redirect to a "session has timed out page". Any ideas?
Code:
private void checkSessionExpired()
{
if (Context.Session != null)
{
if (Session.IsNewSession)
{
string szCookieHeader = Request.Headers["Cookie"];
if ((null != szCookieHeader) && (szCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
Response.Redirect("gblSessionExpired.aspx");
}
}
}
}
I was thinking, an easier way perhaps (I'm new to sessions), is to set a session timeout once at the start. And then check if a session that I set at the start IsNull... would that work? If the session variable is null then redirect to a "session has timed out page". Any ideas?