Cookie不会取消设置 [英] Cookie won't unset

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

问题描述

好的,我很累,一直盯着这个小时。



我在/access/login.php设置一个cookie,代码:

  setcookie('username',$ username,time()+ 604800,'/'); 

当我尝试注销时,它位于/access/logout.php(并重写为/访问/注销),cookie似乎不会取消设置。我试过以下:

  setcookie('username',false,time() -  3600,'/'); 

setcookie('username','',time() - 3600,'/');

setcookie('username','',1,'/');

我也试过直接打/access/logout.php,但它不工作。 / p>

在php日志中没有显示任何内容。



有任何建议吗?我不知道我是否缺少某些东西,或者发生了什么事情,但是这些代码已经有几个小时的时间来尝试调试了。

解决方案

似乎是一个服务器问题。我的最后一个域是相当宽松的PHP错误处理,而新域显示每个错误。我使用这两个网站并排,旧的删除的cookie,因为它应该。


OK, I'm stumped, and have been staring at this for hours.

I'm setting a cookie at /access/login.php with the following code:

setcookie('username', $username, time() + 604800, '/');

When I try to logout, which is located at /access/logout.php (and rewritten to /access/logout), the cookie won't seem to unset. I've tried the following:

setcookie('username', false, time()-3600, '/');

setcookie('username', '', time()-3600, '/');

setcookie('username', '', 1, '/');

I've also tried to directly hit /access/logout.php, but it's not working.

Nothing shows up in the php logs.

Any suggestions? I'm not sure if I'm missing something, or what's going on, but it's been hours of staring at this code and trying to debug.

解决方案

Seems to be a server issue. My last domain was pretty relaxed on PHP error handling while the new domain shows every error. I'm using both sites side by side and the old one removes the cookie as it should.

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

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