我按以下方式设置cookie的到期日期:
var dt = new Date(); dt.setMinutes(dt.getMinutes() + 30); $cookieStore.put("loggedin",true,{ expires: dt })
正在创建cookie,但它的到期时显示为“浏览会话结束时”. WTH?
将配置级别的cookie属性设置为所有cookie(使用moment.js设置到期日期).
angular.module('myApp').config(cookies); function cookies($cookiesProvider,moment) { // site domain like: domine.com $cookiesProvider.defaults.domain = 'yourdomine.com'; // set expiration to next week (+ 1 week) $cookiesProvider.defaults.expires = moment().add(1,'week').calendar(); // see HTTP cookies to view attributes }