如何使用 vb.net 删除单个 cookie 而不是我的所有 cookie,比如可能通过它的名称获取 cookie 并删除它
谢谢
If (Not Request.Cookies("UserSettings") Is Nothing) Then
Dim myCookie As HttpCookie
myCookie = New HttpCookie("UserSettings")
myCookie.Expires = DateTime.Now.AddDays(-1D)
Response.Cookies.Add(myCookie)
End If
直接从这里获得http://msdn.microsoft.com/en-us/library/ms178195(v=vs.100).aspx
尝试这个
Dim currentUserCookie As HttpCookie = HttpContext.Current.Request.Cookies("UserSettings")
HttpContext.Current.Response.Cookies.Remove("UserSettings")
currentUserCookie.Expires = DateTime.Now.AddDays(-10)
currentUserCookie.Value = Nothing
HttpContext.Current.Response.SetCookie(currentUserCookie)