当前位置: 动力学知识库 > 问答 > 编程问答 >

c# - How to remove cookies under 1 domain in CookieContainer

问题描述:

In System.Net.CookieContainer

if I want to remove all cookies under a domain name, how?

网友答案:

You could do something like this.

CookieContainer c = new CookieContainer();
var cookies = c.GetCookies(new Uri("http://www.google.com"));
foreach (Cookie co in cookies)
{
  co.Expires = DateTime.Now.Subtract(TimeSpan.FromDays(1));
}

This will expire all cookies for the domain you specify.

分享给朋友:
您可能感兴趣的文章:
随机阅读: