How do i set the cookie with expiration date with angularjs 1.4. The documentation says to use
expires - {string|Date} - String of the form "Wdy, DD Mon YYYY HH:MM:SS GMT" or a Date object indicating the exact date/time this cookie will expire.
But its not working.My firebug is showing the expiration date as Session only.
HTML
<div ng-app="cookieApp" ng-controller="cookieCtrl">
<button ng-click="setCookie()">Set Cookie</button>
<button ng-click="getCookie()">Get Cookie</button>
</div>
Javascript
var app=angular.module("cookieApp",['ngCookies']);
app.controller("cookieCtrl",function($scope, $cookies){
$scope.setCookie = function(){
console.log("setCookie");
var now = new Date();
now.setDate(now.getDate() + 7);
$cookies.put("tech","angularjs",{expiry:now});
}
$scope.getCookie = function(){
alert( $cookies.get("tech"));
}
});
I tried to set the jsFiddle but i couldnt save it. My alert is showing undefined.