Donate

Remove Cookies From CookieContainer Class

The CookieContainer class does not contain a method that clears or removes the cookies associated with it. To remove them, you have to set each cookie's Expired property to True as shown below.
C#
1
2
3
4
var cookies = cookieContainer.GetCookies(new Uri("http://your_url_example_here"));
foreach (Cookie co in cookies) {
    co.Expired = true;
}

VB.NET
1
2
3
4
Dim cookies = cookieContainer.GetCookies(New Uri("http://your_url_example_here"))
For Each co As Cookie In cookies        
    co.Expired = True
Next

Comments

Donate

Popular Posts From This Blog

WPF CRUD Application Using DataGrid, MVVM Pattern, Entity Framework, And C#.NET

How To Insert Or Add Emojis In Microsoft Teams Status Message

TypeScript Error Or Bug: The term 'tsc' is not recognized as the name of a cmdlet, function, script file, or operable program.