通过JavaScript删除Cookie [英] Delete cookies via JavaScript

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

问题描述


可能重复:

JavaScript cookie delete

请让我知道如何删除特定的Cookie )

Please let me know how to delete specific cookie (I have the name of the cookie its enough..).

我真的没有一个想法(我不知道JS很好...),当我在Google搜索我没有找到好的解决方案。

I really dont have an idea (I dont know JS well...) and when I searched in Google I didn't find a good solution.

谢谢。


如果我不能删除cookie - 让我知道如何将值更改为(空..),它也可以。

If I can't delete the cookie - let me know how to change the value to "" (empty..), its ok too.

推荐答案

此处窃取:

function del_cookie(name) {
   document.cookie = name + '=; expires=Thu, 01-Jan-70 00:00:01 GMT;';
} 



这将cookie值设置为无( name + '=; ),并将过期时间设置为过期(立即过期)。

This sets the cookie value to nothing (name + '=;) and sets the expiration time to the past (expiring it immediately).

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

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