0

如何使用 vb.net 删除单个 cookie 而不是我的所有 cookie,比如可能通过它的名称获取 cookie 并删除它

谢谢

4

2 回答 2

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

于 2013-06-12T23:34:23.547 回答
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)
于 2013-06-13T00:16:19.473 回答