如何从C#禁用浏览器Cookie [英] how to disable browser cookies from c#
本文介绍了如何从C#禁用浏览器Cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好,先生,我想从c#代码中禁用浏览器cookie.
给我解决方案
Hello sir I want to disable browser cookies from c# code.
give me solution
推荐答案
我假设您要删除cookie,请尝试以下操作:
I assume you want to delete cookies, try this:
// First check if cookie exists
if (Request.Cookies["MyCookieName"] != null)
{
// Set its expiration time somewhere in the past
Response.Cookies["MyCookieName"].Expires = DateTime.Now.AddDays(-1);
}
请参考此 [
Refer THIS[^]
for more details about cookies in asp.net.
hope it helps :)
^ ]
这篇关于如何从C#禁用浏览器Cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文