如何从两个不同的路径在php中删除相同的cookie [英] How to delete the same cookie in php from two different path

查看:142
本文介绍了如何从两个不同的路径在php中删除相同的cookie的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的问题是,我想删除从设置cookie但由于路径限制PHP不是删除cookie的页面中的不同目录中的cookie。有任何解决方案吗?

解决方案

当您设置和删除cookie,通过相同的路径:

  setcookie('cookie_name',SOME_VALUE,time()+ 3600,'/'); // to set 

setcookie('cookie_name',,-1,'/'); // to unset

http://php.net/manual/en/function.setcookie.php



http://www.phpbuddy.com/article.php?id=12 p>

My problem is that I want to delete the cookie from the page which is in the different directory from the page who sets the cookie but due to the path restriction PHP is not deleting the cookie. Has anyone any solution?

解决方案

When you set and delete the cookies, pass the same path:

setcookie('cookie_name', "SOME_VALUE", time()+3600, '/');   //to set

setcookie('cookie_name', "", -1, '/');            //to unset

http://php.net/manual/en/function.setcookie.php

http://www.phpbuddy.com/article.php?id=12

这篇关于如何从两个不同的路径在php中删除相同的cookie的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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