代码之家  ›  专栏  ›  技术社区  ›  w00ngy

如何使用asp.net删除或终止Chrome中的cookie

  •  1
  • w00ngy  · 技术社区  · 8 年前

    我正在按按钮添加cookie

    var impersonationCookie = new HttpCookie("UserImp_ImpAuid");
    impersonationCookie.Value = Encode64(auidToImpersonate);
    impersonationCookie.Expires = DateTime.Now.AddDays(1d);
    impersonationCookie.Path = "/";
    Page.Response.Cookies.Add(impersonationCookie);
    

    page_load

    HttpCookie currentUserCookie = HttpContext.Current.Request.Cookies["UserImp_ImpAuid"];
    HttpContext.Current.Response.Cookies.Remove("UserImp_ImpAuid");
    currentUserCookie.Expires = DateTime.Now.AddDays(-10);
    currentUserCookie.Value = null;
    HttpContext.Current.Response.SetCookie(currentUserCookie);
    

    MDAwMDM5OTk2 有效期为 When the browsing session ends .

    enter image description here

    1 回复  |  直到 8 年前
        1
  •  1
  •   w00ngy    8 年前

    正如评论中提到的,这可能是因为chrome设置“继续你离开的地方”。

    您可以在其他浏览器中进行交叉检查。

    Chrome Doesn't Delete Session Cookies

    推荐文章