How to remove all current domain cookies in MVC website?

Viewed 31707

I am working on a MVC website, and in my logout link I want to remove all the current domain cookies.

I tried this:

this.ControllerContext.HttpContext.Response.Cookies.Clear();

and this:

Response.Cookies.Clear();

but both didn't work and the cookies still there.

3 Answers
myCookie.Expires = DateTime.Now.AddDays(-1d);

This does not clear the cookies instantly.

You can use:

myCookie.Expires = DateTime.Now.AddSeconds(1);

To clear cookies instantly

Related