jquery - 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');
}
}
解决方案
推荐阅读
- next.js - 如何在 Next.js 中获取 Cognito 用户服务器端?
- azure-devops - 将 Azure 代理交换为服务
- c++ - 二次探测散列函数 C++
- powershell - 如何在PowerShell中使用管道输入
- c - MPFR 之类的库如何存储和操作任意精度的实数?
- sql-server - 使用从表 b 中检索到的复合键从表 a 中删除的最有效方法是什么?
- google-cloud-platform - GCP PubSub 重试退避时间
- python - Python搜索字符模式,如果存在则缩进
- javascript - TensorFlowJS 画布大小错误 - 如何显示图像?
- flutter - Flutter:如何使用 GetX 查询列表项