2017-05-10 19:29
浏览 82


On my website I set some cookies when users login so I can remember them so they don't have to login every time they re-visit the website.

I set the cookies in php using the following code:

setcookie("last_login", $loginID, time() + (86400 * 30), "/"); // 86400 = 1 day

And in my php.ini I even got this setting:

session.cookie_lifetime = 2592000

But even with all this when i close down the browser and re-open the website the cookies don't work in my php code and they dose not get logged in, but even more weird. Then when i try yo echo the cookie using:

echo $_COOKIE["last_login"];

It in the begining does not show up but sometimes after a few reloads it just randomly starts working with the cookie and it echo it out and you get logged in...?

So how can i make it so the cookies allways work within the next 30 days without it being weird?

图片转代码服务由CSDN问答提供 功能建议

在我的网站上,我在用户登录时设置了一些cookie,这样我就能记住它们,这样他们就不必每次都登录 他们重新访问网站的时间。


  setcookie(“last_login”,  $ loginID,time()+(86400 * 30),“/”);  // 86400 = 1天


session.cookie_lifetime = 2592000

但即便如此,当我关闭浏览器并重新打开网站时,我的PHP代码中的cookie无法正常工作,并且它们无法登录,但更多 奇怪的。 然后当我尝试使用以下方式回复cookie:

  echo $ _COOKIE [“last_login”]; 


那怎么能 我是这样做的,所以饼干总是在接下来的30天内工作,而不是很奇怪?

  • 写回答
  • 好问题 提建议
  • 追加酬金
  • 关注问题
  • 邀请回答

1条回答 默认 最新

相关推荐 更多相似问题