I am trying to reset session_Id before login, and after resetting I am assigning the values to session. This value is not going to new session id. Please help in this issue. Thanks in advance.
protected void Button1_Click(object sender, EventArgs e)
{
Session.Clear();
Session.Abandon();
Response.Cookies.Add(new HttpCookie("ASP.NET_SessionId", ""));
Session["name"] = "athil";
Response.Redirect("webform1.aspx");
}
Button1_Click()
event contains the value "Athil" in Session["name"]
. This is because the Session object is not destroyed until the server has finished processing.
When you redirect and access the Session["name"]
on a subsequent Web page, it is empty. This is because Session["name"]
is destroyed with the previous Session object when the page finished processing.
New Session object is created when you open a subsequent Web page, after abandoning a session. You can store variables and objects in this new Session object.