Unable to delete/modify cookie
-
I have a cookie that has been set a value and expiration date to be a year from the date created. I am not able to change or delete the cookie. below is my code: private void RDCookie() { Request.Cookies.Remove("SaveEmail2"); Response.Write(Request.Cookies["SaveEmail2"].Value); } The second line will fail because the cookie was removed before it could be displayed. However, if I have this: private void Page_Load() { Request.Cookies.Remove("SaveEmail2"); } and a button click event: private void Button1_Click(object sender, System.EventArgs e) { Response.Write(Request.Cookies["SaveEmail2"].Value); } it'd still display the value. Same thing with modifying the cookie value. If I read the cookie value immediately after modification it shows the new value but after I refreshes the page the value is changed to the old value.
-
I have a cookie that has been set a value and expiration date to be a year from the date created. I am not able to change or delete the cookie. below is my code: private void RDCookie() { Request.Cookies.Remove("SaveEmail2"); Response.Write(Request.Cookies["SaveEmail2"].Value); } The second line will fail because the cookie was removed before it could be displayed. However, if I have this: private void Page_Load() { Request.Cookies.Remove("SaveEmail2"); } and a button click event: private void Button1_Click(object sender, System.EventArgs e) { Response.Write(Request.Cookies["SaveEmail2"].Value); } it'd still display the value. Same thing with modifying the cookie value. If I read the cookie value immediately after modification it shows the new value but after I refreshes the page the value is changed to the old value.