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");
}
}

Michal HabalcikRank #902 · 2.3K reputationPosted Jan 6, 2015, 11:44 PM EST
Here is a tutorial directly from MSDN: How to delete a cookie
shi lianghong48 reputationPosted Jan 8, 2015, 5:07 PM EST
Try something like that:
if (Request.Cookies["userId"] != null) { Response.Cookies["userId"].Expires = DateTime.Now.AddDays(-1); }But it also makes sense to use
besides in many scenarios.