删除Cookie时出现的问题,不会取消设置 [英] Problems deleting cookies, won't unset

查看:163
本文介绍了删除Cookie时出现的问题,不会取消设置的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图搜索php手册和互联网上如何删除cookie,我已经尝试过它们都说同样的方式:

I've tried searching the php manual and internet on how to delete cookies and I've tried it the exact same way they all say:

setcookie("name", '', 1);

setcookie("name", '', time()-3600);

但是当我在Firefox的cookie对话框中检查cookie时,它仍然有相同的值。
我使用以下行设置此cookie:

But when I check the cookies in the cookies dialog in Firefox, it's still there with the same value. I set this cookie using the following line:

setcookie("name", $value, time() + 259200, $path);

我发现这个问题在stackoverflow:
,但没有答案解决了这个问题。

I found this question on stackoverflow: , but none of the answers solved the problem. I also tried putting all paramaters in, like the author said, but it had no effect.

有没有人看到这个问题?

Does anyone see the problem?

推荐答案

手册指出< a>:

The manual states:


Cookie必须使用与设置相同的参数进行删除。如果value参数是空字符串或 FALSE ,并且所有其他参数匹配以前对setcookie的调用,则具有指定名称的cookie将从远程客户端。这通过将值设置为已删除并将到期时间设置为过去的一年来在内部实现。

Cookies must be deleted with the same parameters as they were set with. If the value argument is an empty string, or FALSE, and all other arguments match a previous call to setcookie, then the cookie with the specified name will be deleted from the remote client. This is internally achieved by setting value to 'deleted' and expiration time to one year in past.

因此,请确保正确指定 $ path >也在删除时。例如,如果在子目录中指定了cookie,您可能无法从父目录或子目录(或两者)中删除它。

So also make sure that $path is specified correctly -- also when deleting it. For instance, if the cookie was specified in a subdirectory, you may not be able to delete it from either the parent or children directories (or both).

不完全确定权限的工作方式,但您可能想使用网络开发者工具栏来查看您尝试删除的Cookie的路径

I'm not entirely sure how the permissions work, but you might want to use the Web Developer Toolbar to view what the path is of the cookie you are attempting to delete.

这篇关于删除Cookie时出现的问题,不会取消设置的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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