function myCookieCreator(){
document.cookie="myCoookie=isTrueSet; expires=Thu, 30 Mar 2017
12:00:00 UTC";
}
我可以在同一行代码中创建之日起14天后过期吗?这就是我创造它的方式。
答案 0 :(得分:0)
By Default, the cookie deleted when the browser is closed but its expiry date can be set to some other date like-:
获取当前日期。 添加14天。 并将新的变量放在过期的位置。
var newDate = new Date();
var dateAdd = newDate.setDate(today.getUTCDate()+14);
document.cookie = "expires=+dateAdd+";