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 #
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 #
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.
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");