Delete cookies from navigating by methodo C # [closed]

0

Good afternoon Community,

I want to know if there is any way to click on a button that can delete the cookies that the browser has.

This management would be by c #

    
asked by Oscar Diaz 07.04.2017 в 21:48
source

2 answers

2

It depends on the browser, since everyone does not store the cookies in the same file. In the case of Google Chrome that saves cookies in:

  

C: \ Users (User) \ AppData \ Local \ Google \ Chrome \ User Data \ Cookies

The code in C # seria,

System.IO.File.Delete(@"C:\Users\(User)\AppData\Local\Google\Chrome\User
Data\Cookies");

In the case of other browsers you will have to look in your documentation where the file is located where they keep their cookies and delete them.

    
answered by 07.04.2017 в 22:06
-1

Do you want to delete those from your website or all of the browser's? You could try this ...

string[] cookies = Request.Cookies.AllKeys;
    foreach (string cookie in cookies)
    {
        BulletedList1.Items.Add("Deleting " + cookie);
        Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);
    }

or if you need to delete all of the browser, you can directly delete the file in which they are saved with System.IO.File.Delete ("Path of the file");

    
answered by 07.04.2017 в 22:15