Reputation: 469
I have some html page that save some cookie, the broswer remember the cookie all time when browser is open (I can see the value even if I'm navigating to other page and then backs to my html page). but if I close the broswer I can't see anymore that value
I have something like:
$("#mybutton").click(function () {
setCookie("username", "some name");
});
and then onload:
$(document).ready(function () {
document.write(getCookie("username"));
});
Even that history checkbox unchecked:
Upvotes: 0
Views: 39
Reputation: 11335
Looks like you are setting the cookie using PHP code. You are not setting an expiry and by default, cookies should expire on browser close.
I suggest you set the time to expire the cookie.
Example:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
?>
Reference:
Upvotes: 1