首页 > 解决方案 > jquery addcookie - 指定路径

问题描述

我们有一个“我们如何帮助”向上滑动,我已经设法添加了 cookie,如果用户关闭它,它会关闭幻灯片再次显示。

我无法为整个域指定路径,目前路径设置为当前页面,这对于该页面但不是整个域都可以。

加载的主体将检查 cookie,这是有效的,但路径不是。

非常感谢任何帮助。提前致谢!

$(document).ready(function(e) {
    $('#closeButton').click(function() {
      var $this = $(this);
      if($this.data('clicked')) {

      } else {
        $('.welcomepop').addClass('hide');
        addCookie(10);
      }
  });
});

 function addCookie(exdays) {
  var d = new Date();
  d.setTime(d.getTime() + (exdays*24*60*60*1000));
  var expires = "expires=" + d.toGMTString();
    var path = "path:'/'"
  document.cookie = expires, + path;
}

function checkCookie() {
  if (document.cookie == false) {
      //alert("Welcome New User");
  } else if (document.cookie.indexOf("expires") >= 0) {
        $('.welcomepop').addClass('hide');
  }
}

标签: jquerysession-cookiesjquery-cookie

解决方案


推荐阅读