protected void Page_Load(object sender, EventArgs e)
{
//if (Request.Cookies["Prno"] != null)
//{
// HttpCookie myCookie = new HttpCookie("Prno");
// myCookie.Value = String.Empty;
// myCookie.Expires = DateTime.Now.AddYears(-1);
// Response.Cookies.Add(myCookie);
// Response.Cookies.Remove("Prno");
//}
HttpCookie myCookie = new HttpCookie("Prno");
//Here, we are setting the time to a previous time.
//When the browser detect it next time, it will be deleted automatically.
myCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(myCookie);
//Request.Cookies["Prno"].Expires = DateTime.Now;
Session.Abandon();
Session.Clear();
Response.Cookies.Clear();
Response.Redirect("~/Login.aspx");
}
}
shi lianghongPosted Jan 8, 2015, 10:07 PM
Try something like that:
But it also makes sense to use
besides in many scenarios.
Michal HabalcikPosted Jan 7, 2015, 4:44 AM
Here is a tutorial directly from MSDN: How to delete a cookie