无法删除php set cookie
发布时间:2020-12-13 18:17:33 所属栏目:PHP教程 来源:网络整理
导读:我在php中通过这个调用设置了一个cookie setcookie('alert_msg','you have the add badge'); 我试过这样解开它 setcookie('alert_msg','');setcookie('alert_msg',false);setcookie('alert_msg',false,1);setcookie('alert_msg',time()-3600);setcookie('ale
我在php中通过这个调用设置了一个cookie
setcookie('alert_msg','you have the add badge'); 我试过这样解开它 setcookie('alert_msg',''); setcookie('alert_msg',false); setcookie('alert_msg',false,1); setcookie('alert_msg',time()-3600); setcookie('alert_msg','',1,'/'); 并且它仍然不会取消$_COOKIE [‘alert_msg’]中的cookie值. 我试过Firefox和Chrome 代码示例: if (isset($_COOKIE['alert_msg'])) { $this->set('alert_msg',$_COOKIE['alert_msg']); unset($_COOKIE['alert_msg']); setcookie('alert_msg','/'); }
检查cookie路径.
由于您没有将path参数传递给setcookie函数,因此在这种情况下,cookie将仅为当前目录设置并且可以使用,并且只能从该目录中取消设置. 可能的解决方案是将路径值传递为/.因此,cookie可以在应用程序的任何部分使用和取消设置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |