简体   繁体   English

无法在LocalHost上设置Cookie过期时间

[英]Unable to Set Cookie Expiration Time on LocalHost

I am writing a cookie and trying to set the expiration time in my localhost. 我正在编写一个cookie并尝试在本地主机中设置到期时间。 However, it is always showing Ending time as "When browsing session ends" 但是,它总是显示“结束时间”为“浏览会话结束时”

Here is the code 这是代码

$domain = ($_SERVER['HTTP_HOST'] != 'localhost') ? $_SERVER['HTTP_HOST'] : false;
setcookie('rememberme', $cookie, time()+86400*7, '/', $domain, false);

Can someone please help me on why I am facing this issue? 有人可以帮我解决为什么遇到这个问题吗?

在此处输入图片说明

This is causing my cookie to get destroyed every time I close my browser. 这导致我每次关闭浏览器时都会破坏cookie。

I was able to fix the issue myself. 我自己可以解决此问题。 There was some other issue in my code. 我的代码中还有其他问题。 Apologies for the inconvenience. 不便之处敬请原谅。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM