How to delete or expire cookie in Chrome using asp.net

This is one of those dumb questions. The answer should be simple, but it doesn’t seem to be working. Anyone have any ideas where else for me to look for some rep?

I’m adding a cookie on a button click

var impersonationCookie = new HttpCookie("UserImp_ImpAuid");
impersonationCookie.Value = Encode64(auidToImpersonate);
impersonationCookie.Expires = DateTime.Now.AddDays(1d);
impersonationCookie.Path = "/";
Page.Response.Cookies.Add(impersonationCookie);

I’m expiring a cookie and clearing the value on a page_load

HttpCookie currentUserCookie = HttpContext.Current.Request.Cookies["UserImp_ImpAuid"];
HttpContext.Current.Response.Cookies.Remove("UserImp_ImpAuid");
currentUserCookie.Expires = DateTime.Now.AddDays(-10);
currentUserCookie.Value = null;
HttpContext.Current.Response.SetCookie(currentUserCookie);

Chrome (v 69) still shows the cookie with the value MDAwMDM5OTk2 and with an expiration date of When the browsing session ends.

enter image description here

I’ve tried plenty of variations from other questions

Here is Solutions:

We have many solutions to this problem, But we recommend you to use the first solution because it is tested & true solution that will 100% work for you.

Solution 1

As mentioned in the comment, This could be because chrome setting “Continue where you left off”.

You can cross check in a different browser.

Chrome Doesn’t Delete Session Cookies

Note: Use and implement solution 1 because this method fully tested our system.
Thank you 🙂

All methods was sourced from stackoverflow.com or stackexchange.com, is licensed under cc by-sa 2.5, cc by-sa 3.0 and cc by-sa 4.0

Leave a Reply