我如何删除单个cookie而不是所有使用vb.net的cookie,比如可能通过它的名字获取cookie并将其删除
由于
答案 0 :(得分:0)
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
答案 1 :(得分:0)
试试这个
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)