Reputation: 5428
I cannot seem to delete cookies with Angularjs. What can be wrong.. Her is the code..
$scope.adminLogout = function(){
$http({
url: '/AdServerLongTail/adminapi/logout',
method: "POST",
dataType:"json",
}).success(function (data, status, headers, config) {
console.log("success");
delete $cookies["username"];
delete $cookies["JSESSIONID"];
$rootScope.welcome=null;
$location.path("/admin");
}).error(function (data, status, headers, config) {
console.log("error");
});
}
html
<li><a href="#" ng-click="adminLogout()">LOGOUT</a></li>
Upvotes: 2
Views: 950
Reputation: 1385
From the docs - cookies will get update at the end of the current $eval cycle (which is part of the $digest cycle). This means you might not see the cookies deleted straight away.
On a slightly different not the Angularjs Cookies library is quite broken and should not be used for any production ready project (for example you can't set expire time etc.)
Upvotes: 1