删除cookies [英] Delete Cookies

查看:99
本文介绍了删除cookies的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



我想在页面加载时删除cookie.
我没有设置任何炊具.
但是我需要删除系统中的现有Cookie.

谢谢,
Ananth

Hi,

I want ot delete the cookies when the page is loaded.
I didnot set any cookis.
But I need to delete the existing cookies in the system

Thanks,
Ananth

推荐答案

尝试:
void Page_Load()    
{        
    string[] cookies = Request.Cookies.AllKeys;        
    foreach (string cookie in cookies)        
    {                         
       Response.Cookies[cookie].Expires = DateTime.Now.AddDays(-1);        
    } 
}


您还可以使用Java脚本删除Cookie:

检查以下文章:

1. http://www.brenz.net/cookies/delete_cookie.asp?absent [ ^ ]

2. http://stackoverflow.com/questions/595228/how- can-i-delete-all-cookies-with-javascript [
You can delete a cookie using Javascript also:

check the following article:

1.http://www.brenz.net/cookies/delete_cookie.asp?absent[^]

2.http://stackoverflow.com/questions/595228/how-can-i-delete-all-cookies-with-javascript[^]


我不知道您为什么需要删除所有cookie. .

Response.Cookies.Remove(cookiename).

像这样.
I dont know why do you require to delete all the cookies.Rather clear cookies just by its name.

Response.Cookies.Remove(cookiename).

like this.


这篇关于删除cookies的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆