如何使用asp.net在Chrome中删除或过期cookie [英] How to delete or expire cookie in Chrome using asp.net
问题描述
这是那些愚蠢的问题之一。答案应该很简单,但似乎没有用。有人对我还有其他想法吗?
This is one of those dumb questions. The answer should be simple, but it doesn't seem to be working. Anyone have any ideas where else for me to look for some rep?
我在单击按钮时添加了一个cookie
I'm adding a cookie on a button click
var impersonationCookie = new HttpCookie("UserImp_ImpAuid");
impersonationCookie.Value = Encode64(auidToImpersonate);
impersonationCookie.Expires = DateTime.Now.AddDays(1d);
impersonationCookie.Path = "/";
Page.Response.Cookies.Add(impersonationCookie);
我要终止Cookie并清除 page_load上的值
I'm expiring a cookie and clearing the value on a 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);
Chrome浏览器(v 69)仍显示值为 MDAwMDM5OTk2的cookie
,且到期日期为浏览会话结束时。
Chrome (v 69) still shows the cookie with the value MDAwMDM5OTk2
and with an expiration date of When the browsing session ends
.
我尝试了其他问题的多种解决方法
I've tried plenty of variations from other questions
- Delete a cookie on signing out
- How to delete a cookie from .net
- How to delete cookies on an asp.net website
推荐答案
如评论中所述,这可能是因为铬
As mentioned in the comment, This could be because chrome setting "Continue where you left off".
您可以交叉检查其他浏览器。
You can cross check in a different browser.
这篇关于如何使用asp.net在Chrome中删除或过期cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!