开发者

Cookies not updating in 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 开发者_StackOverflowvalues

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?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜