关闭 Internet Explorer 后 Cookie 为空
Cookie empty after closing internet explorer
我有一些 html 页面保存了一些 cookie,当浏览器打开时,浏览器会一直记住 cookie(即使我导航到其他页面然后返回我的页面,我也能看到该值html 页)。
但是如果我关闭浏览器,我就看不到那个值了
我有类似的东西:
$("#mybutton").click(function () {
setCookie("username", "some name");
});
然后加载:
$(document).ready(function () {
document.write(getCookie("username"));
});
甚至未选中该历史记录复选框:
看起来您正在使用 PHP 代码设置 cookie。您没有设置过期时间,默认情况下,cookie 应在浏览器关闭时过期。
我建议您设置 cookie 的过期时间。
示例:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
?>
参考:
我有一些 html 页面保存了一些 cookie,当浏览器打开时,浏览器会一直记住 cookie(即使我导航到其他页面然后返回我的页面,我也能看到该值html 页)。 但是如果我关闭浏览器,我就看不到那个值了
我有类似的东西:
$("#mybutton").click(function () {
setCookie("username", "some name");
});
然后加载:
$(document).ready(function () {
document.write(getCookie("username"));
});
甚至未选中该历史记录复选框:
看起来您正在使用 PHP 代码设置 cookie。您没有设置过期时间,默认情况下,cookie 应在浏览器关闭时过期。
我建议您设置 cookie 的过期时间。
示例:
<?php
$value = 'something from somewhere';
setcookie("TestCookie", $value, time()+3600); /* expire in 1 hour */
?>
参考: