【发布时间】:2010-06-03 15:00:16
【问题描述】:
我正在尝试删除一个 cookie,但不知何故它没有在 IE 8 中被删除
这是我正在使用的代码
HttpCookie userCookie = Request.Cookies[cookieName];
if (userCookie != null)
{
userCookie.Expires = DateTime.Now.AddDays(-1);
if (!string.IsNullOrEmpty(cookieDomain))
userCookie.Domain = cookieDomain;
Response.Cookies.Add(userCookie);
}
它在 firfox 和 chrome 中运行良好。
假设 cookie 的名称是 testcookie。我们从 xyz.com 创建了这个 cookie,并将 cookie 的域设置为“.xyz.com”。现在我们正在从 subdomain.xyz.com 中删除或过期这个 cookie。我们正在使用上面提到的代码删除 cookie。
【问题讨论】: