I don’t know what I am doing wrong here when trying to delete cookie… can someone help? Here is code which I am trying to delete cookie.
if (Request.Cookies["RememberUser"] != null)
{
HttpCookie objCookie = Request.Cookies["RememberUser"];
objCookie.Expires = DateTime.Now.AddDays(-1d);
Response.Cookies.Add(objCookie);
}
Is above code is right to delete cookie, for some reason this is not working…
This code is not working even when I tried to update cookies with
Response.Cookies.Set(objCookie);.
the above code is worked.i’m surprising why you can’t delete.the problem may be appear in your create cookie code.
the first time access with no cookie and response header from server.
Response Headers:
access again with cookie and response header from server.
Response Headers:
and Request Headers:
you can use
firebugwith firefox or thefiddlersoftware to tracking response and request and see why can’t delete cookie.good luck.