扫码关注官方订阅号
angularJS 在使用$cookies的时候,如何设置cookie的保存时间
我是答案的搬运工: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}); }]);
微信扫码关注PHP中文网服务号
QQ扫码加入技术交流群
Copyright 2014-2025 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
PHP学习
技术支持
返回顶部
我是答案的搬运工:
http://stackoverflow.com/questions/12624181/angularjs-how-to-set-expiration-date-for-cookie-in-angularjs