简体   繁体   中英

Unable to Set Cookie Expiration Time on LocalHost

I am writing a cookie and trying to set the expiration time in my localhost. 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.

I was able to fix the issue myself. There was some other issue in my code. Apologies for the inconvenience.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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