Home > Backend Development > PHP Tutorial > php-cookie - PHP 无法删除cookie

php-cookie - PHP 无法删除cookie

WBOY
Release: 2016-06-06 20:14:06
Original
879 people have browsed it

//$cookie保留时间
//$falg 用户唯一标识符
//$name 用户名
//设置cookie信息
function _setcookie($name,$flag,$time)
{

<code>switch($time)
{
    case 0:
        setcookie('username',$name);
        setcookie('userflag',$flag);
        _alert_location('登录成功', 'index.php');
        break;
    case 1:
        setcookie('username',$name,time()+86400);
        setcookie('userflag',$flag,time()+86400);
        _alert_location('登录成功', 'index.php');
        break;
    case 2:
        setcookie('username',$name,time()+604800);
        setcookie('userflag',$flag,time()+604800);
        _alert_location('登录成功', 'index.php');
        break;
}</code>
Copy after login
Copy after login

}
?>php-cookie - PHP 无法删除cookie
php-cookie - PHP 无法删除cookie
php-cookie - PHP 无法删除cookie

IE和火狐下都无法删除 请问是什么原因啊?

setcookie("username","",time()-1);
setcookie("userflag","",time()-1);

这样也不行

我已经解决~是path的问题
setcookie("username","",time()-1,'/My_Dome%201.0/');
这个样子就好了~但是很奇怪本地调试的时候为什么要加上'/My_Dome%201.0/'才行呢 不能是'/'吗?网站正式上线后 怎么修改呢?

更郁闷的是 火狐下和iE下的path不一样~
setcookie("username","",time()-1,'/My_Dome%201.0/'); //火狐下删除方式
setcookie("userflag","",time()-1,'/My_Dome%201.0/');
setcookie("username","",time()-1,'/My_Dome%201.0'); //IE下删除方式
setcookie("userflag","",time()-1,'/My_Dome%201.0');

出现这种问题请问有什么好的解决方式~

回复内容:

//$cookie保留时间
//$falg 用户唯一标识符
//$name 用户名
//设置cookie信息
function _setcookie($name,$flag,$time)
{

<code>switch($time)
{
    case 0:
        setcookie('username',$name);
        setcookie('userflag',$flag);
        _alert_location('登录成功', 'index.php');
        break;
    case 1:
        setcookie('username',$name,time()+86400);
        setcookie('userflag',$flag,time()+86400);
        _alert_location('登录成功', 'index.php');
        break;
    case 2:
        setcookie('username',$name,time()+604800);
        setcookie('userflag',$flag,time()+604800);
        _alert_location('登录成功', 'index.php');
        break;
}</code>
Copy after login
Copy after login

}
?>php-cookie - PHP 无法删除cookie
php-cookie - PHP 无法删除cookie
php-cookie - PHP 无法删除cookie

IE和火狐下都无法删除 请问是什么原因啊?

setcookie("username","",time()-1);
setcookie("userflag","",time()-1);

这样也不行

我已经解决~是path的问题
setcookie("username","",time()-1,'/My_Dome%201.0/');
这个样子就好了~但是很奇怪本地调试的时候为什么要加上'/My_Dome%201.0/'才行呢 不能是'/'吗?网站正式上线后 怎么修改呢?

更郁闷的是 火狐下和iE下的path不一样~
setcookie("username","",time()-1,'/My_Dome%201.0/'); //火狐下删除方式
setcookie("userflag","",time()-1,'/My_Dome%201.0/');
setcookie("username","",time()-1,'/My_Dome%201.0'); //IE下删除方式
setcookie("userflag","",time()-1,'/My_Dome%201.0');

出现这种问题请问有什么好的解决方式~

看看 path 和 domain 是不是写错了。

Related labels:
source:php.cn
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template