3
votes

I set the php expiration to 1 week; if leave the page and come back the cookie's still stored. When I close the browser completely it loses the stored cookie. The browser is not set to clear cookies after exit. (failed in chrome, firefox, safari)

setcookie("pass", "key", time()+259200, "/", ".domain.com" );

1
what returns time() + 259200, maybe server is set with the wrong date? Check the response headers as well, to see what the Set-Cookie header looks like - Maxim Krizhanovsky
259200 is a number I set manually. The server's date is right too. The header's show that the cookie is stored correctly, it's just weird that it loses it when I exit any browser. - Miko
Please post the exact Set-Cookie header you've receiving, so we can take a closer look :) - Maxim Krizhanovsky
Set-Cookie: user=testing; expires=Sat, 17-Sep-2011 14:10:55 GMT; path=/; domain=./cutout/.com - Miko

1 Answers

0
votes

I don't know if this helps. But I do this to set a cookie. Been working for years

$cookie_expire = time() + (86400 * '7';
$domain = $_SERVER["HTTP_HOST"];

if (empty($_COOKIE['entry'])){
$entry_cookie = $_SERVER['HTTP_REFERER'];
setcookie('entry', $entry_cookie , $cookie_expire , '/', $domain  , FALSE, TRUE);
}