dongxian7489 2011-03-10 21:33
浏览 132
已采纳

Cookies没有在PHP中更新

Ok I have code that I have used for years and all of a sudden it stopped working and I have no idea how to fix

first I log in and these cookies are set

setcookie ("memid", $login->id, strtotime("+1 day"), "/");
setcookie ("package",  $login->package, strtotime("+1 day"), "/");
setcookie ("website",  $login->domain, strtotime("+1 day"), "/");
setcookie ("type",  'main', strtotime("+1 day"), "/");
setcookie ("category",  $login->category, strtotime("+1 day"), "/");

This works fine now when I changing something and I update the values

setcookie ("website", $_GET['website'], strtotime("+1 day"), "/");
setcookie ("type", $_GET['type'], strtotime("+1 day"), "/");

Now instead of updating the values of the previous cookies, it creates new cookies with same name new values. I assume the first cookies set are still being read because nothing in my app changes.

Even my logout script where I expire the cookies stopped working

setcookie('memid', '', time()-1000,"/");
setcookie ("package", '', time()-1000,"/");
setcookie ("website", '', time()-1000,"/");
setcookie ("type", '', time()-1000,"/");
setcookie ("account", '', time()-1000,"/");
setcookie ("permissions", '', time()-1000,"/");
setcookie ("category", '', time()-1000,"/");

Any ideas?

  • 写回答

1条回答 默认 最新

  • douquejituan938904 2011-03-11 02:10
    关注

    I suspect that you are setting cookies for a domain like localhost. At least some browsers ignore cookies set for domains that do not have at least one TLD (even if it is invented like .local) and a name before it. So, if you are trying your code under localhost, that may be the problem.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 C# TCP服务端,客户端退出后,不断有数据进来
  • ¥15 HLs设计手写数字识别程序编译通不过
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?
  • ¥15 matlab(相关搜索:紧聚焦)
  • ¥15 基于51单片机的厨房煤气泄露检测报警系统设计
  • ¥15 路易威登官网 里边的参数逆向
  • ¥15 Arduino无法同时连接多个hx711模块,如何解决?