spez
spez

Reputation: 469

Cookie empty after closing internet explorer

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:

enter image description here

Upvotes: 0

Views: 39

Answers (1)

Deepak-MSFT
Deepak-MSFT

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:

PHP setcookie

Upvotes: 1

Related Questions