angular.js - angularJS怎么设置cookies保存的时间
世界只因有你
世界只因有你 2017-05-15 16:58:24
0
1
559

angularJS 在使用$cookies的时候,如何设置cookie的保存时间

世界只因有你
世界只因有你

reply all(1)
淡淡烟草味

I'm the porter of the answer:
http://stackoverflow.com/questions/12624181/angularjs-how-to-set-expiration-date-for-cookie-in-angularjs

angular.module('cookiesExample', ['ngCookies'])
.controller('ExampleController', ['$cookies', function($cookies) {
  // Find tomorrow's date.
  var expireDate = new Date();
  expireDate.setDate(expireDate.getDate() + 1);
  // Setting a cookie
  $cookies.put('myFavorite', 'oatmeal', {'expires': expireDate});
}]);
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template