你如何删除HttpOnly cookie?

时间:2023-01-11 07:29:28

If my application places HttpOnly cookies on a client and then needs to remove them how can you remove them completely?

如果我的应用程序将HttpOnly cookie放在客户端上,然后需要删除它们,你怎么能完全删除它们?

2 个解决方案

#1


11  

You can cause the cookie to expire when the user visits your website, for example:

您可以在用户访问您的网站时使Cookie过期,例如:

HttpCookie expiredCookie = new HttpCookie(cookieName);
expiredCookie.Expires = DateTime.UtcNow.AddDays(-1);
Response.Cookies.Add(expiredCookie);

You'll have to do this for every cookie you want to be removed.

您必须为要删除的每个cookie执行此操作。

#2


0  

You can't reach out and delete cookies. You can take all the cookies, wipe out the data and make them expired though.

您无法伸出并删除Cookie。您可以获取所有Cookie,清除数据并使其过期。

#1


11  

You can cause the cookie to expire when the user visits your website, for example:

您可以在用户访问您的网站时使Cookie过期,例如:

HttpCookie expiredCookie = new HttpCookie(cookieName);
expiredCookie.Expires = DateTime.UtcNow.AddDays(-1);
Response.Cookies.Add(expiredCookie);

You'll have to do this for every cookie you want to be removed.

您必须为要删除的每个cookie执行此操作。

#2


0  

You can't reach out and delete cookies. You can take all the cookies, wipe out the data and make them expired though.

您无法伸出并删除Cookie。您可以获取所有Cookie,清除数据并使其过期。