javascript – 浏览器重启后jquery cookie消失了吗?

我使用 https://github.com/carhartl/jquery-cookie/blob/master/jquery.cookie.js作为cookie功能.

我的问题是浏览器重启后cookie似乎被删除了?

以下是代码摘要,

if ( $.cookie("latlng") ) {
  myLatlng = $.cookie('latlng').split(',');
  myLatlng = new google.maps.LatLng(myLatlng[0],myLatlng[1]);
 } else {
  $.cookie("latlng","3.139,101.686",{ path: '/' });
  myLatlng = new google.maps.LatLng(3.139,101.686);
 }

 ...

 google.maps.event.addListener(marker1,'dragend',function() {
  var temp = marker1.getPosition().lat() + ',' + marker1.getPosition().lng()
  $.cookie("latlng",temp,{ path: '/' });
 });

解决方法

添加过期值.在7天后到期:
$.cookie("latlng",{ path: '/',expires:7 })

相关文章

页面搜索关键词突出 // 页面搜索关键词突出 $(function () {...
jQuery实时显示日期、时间 html: <span id=&quot...
jQuery 添加水印 <script src="../../../.....
中文:Sys.WebForms.PageRequestManagerParserErrorExceptio...
1. 用Response.Write方法 代码如下: Response.Write(&q...
Jquery实现按钮点击遮罩加载,处理完后恢复 思路: 1.点击按...