Z
zee
Iam having problem with IsNewSession can any1 plz help me to run this
code
which is listed on many websites
this is my code for validating session
-----------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
if (Context.Session != null)
{
if (Context.Session.IsNewSession)
{
string sCookieHeader = Page.Request.Headers["Cookie"];
if ((null != sCookieHeader) &&
(sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
if (Page.Request.IsAuthenticated)
{
FormsAuthentication.SignOut();
}
Server.Transfer("SessionTimeout.aspx");
}
}
}
}
---------------------------------------------------
The problem is "every time its showing IsNewSession=true "
and what confusing is let say i have a login page
protected void LoginButton_Click(object sender, EventArgs e)
{
if (txtUName.Text.Trim() ==
ConfigurationManager.AppSettings["UserName"].Trim() &&
txtPassword.Text.Trim() ==
ConfigurationManager.AppSettings["Password"].Trim())
{
FormsAuthentication.SetAuthCookie(txtUName.Text, false);
// Session["Problem"] ="hello";
Response.Redirect("adminindex.aspx");
}
else
litFailureText.Text = "Your login attempt was not
successful, please try again";
}
In the above code u can see "//Session["Problem"] ="hello" " which is
commented so then it redirect to "adminindex.aspx" its shows
IsNewSession=true
If i undo the comment like this "Session["Problem"] ="hello"" then on
"adminindex.aspx" it will show
IsNewSession=false;
Why its necessay to set any session variable at login to run this code
help
code
which is listed on many websites
this is my code for validating session
-----------------------------------------------------------------------------
protected void Page_Load(object sender, EventArgs e)
{
if (Context.Session != null)
{
if (Context.Session.IsNewSession)
{
string sCookieHeader = Page.Request.Headers["Cookie"];
if ((null != sCookieHeader) &&
(sCookieHeader.IndexOf("ASP.NET_SessionId") >= 0))
{
if (Page.Request.IsAuthenticated)
{
FormsAuthentication.SignOut();
}
Server.Transfer("SessionTimeout.aspx");
}
}
}
}
---------------------------------------------------
The problem is "every time its showing IsNewSession=true "
and what confusing is let say i have a login page
protected void LoginButton_Click(object sender, EventArgs e)
{
if (txtUName.Text.Trim() ==
ConfigurationManager.AppSettings["UserName"].Trim() &&
txtPassword.Text.Trim() ==
ConfigurationManager.AppSettings["Password"].Trim())
{
FormsAuthentication.SetAuthCookie(txtUName.Text, false);
// Session["Problem"] ="hello";
Response.Redirect("adminindex.aspx");
}
else
litFailureText.Text = "Your login attempt was not
successful, please try again";
}
In the above code u can see "//Session["Problem"] ="hello" " which is
commented so then it redirect to "adminindex.aspx" its shows
IsNewSession=true
If i undo the comment like this "Session["Problem"] ="hello"" then on
"adminindex.aspx" it will show
IsNewSession=false;
Why its necessay to set any session variable at login to run this code
help