how to check session upon start in masterpage or in global.asax
- by user572276
i am new in asp.net form authentication and sessions
i would like to know how to save session in masterpage or in global.asax
and how to clear session
how to better handle session timeout by redirecting to a page
this is my web.config session settings
<sessionState mode="InProc" cookieless="false" timeout="1"></sessionState>
code in my masterpage
if (Request.Url.AbsolutePath.EndsWith("SessionExpired.aspx", StringComparison.InvariantCultureIgnoreCase))
{
HtmlMeta meta = new HtmlMeta();
meta.HttpEquiv = "Refresh";
meta.Content = "7; URL=./Login.aspx";
Page.Header.Controls.Add(meta);
}
else
HttpContext.Current.Response.AppendHeader("Refresh", Convert.ToString((Session.Timeout * 60)) + "; Url=./Public/SessionExpired.aspx");