How to clear all cookies?

I am looking for the best way to clean / clear all existing cookies when they visit a website and are not authenticated.

We do not allow the customer the ability to “remember me” in order to remain in the system. So, when they visit again, what is the best way to start with cookies?

Is it possible to set all cookies to an empty line? Set cookie date yesterday?

Any example would be much appreciated.

+3
source share
2 answers

Daniel K is right, cookie expiration is the best option. Your question says that you want to clear ALL cookies, you can do this through the Response object:

For Each cookie in Response.Cookies
    Response.Cookies(cookie).Expires = DateAdd("d",-1,now())
Next

cookie "" - , cookie , , , .expires

+12

asp.net #

string[] ck = Request.Cookies.AllKeys;
foreach(string cookie in ck){
   Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
}
+1

All Articles