I have seen all the questions regarding this topic in SO.However I cannot seem to get the cookie value even after implementing.I am a newbie at this.So please forgive me for the lack of understanding.
I am sending correct login credentials via angular ajax to server which is returning a Set-Cookie property having a value.I cannot get this cookie value even after using $cookies and implementing it within $timeout.
Below is my service code:
userOperation.loginService = function(username,password){
return $http({
method: 'POST',
withCredentials: true,
url: urlService.baseUrl+'login',
headers: {'Content-Type': 'application/x-www-form-urlencoded','Accept':'application/x-www-form-urlencoded'},
data:"username="+username+"&password="+password+"&AUTH_TYPE=RESTAUTH",
}).then(function successCallback(response){
console.log(response);
return response;
},function errorCallback(response){
console.log(response);
return response;
});
}
And the controller implementing it
app.controller('logInCtrl',function($scope,$http,$browser,$cookies,userOperation,pnotifyService,$rootScope,$timeout){
$scope.login = function(){
userOperation.loginService($scope.username,$scope.password).then(function(response){
console.log(response);
$timeout(function(){
console.log($cookies.get('JSESSIONID'));
console.log($cookies);
},4000);
});
}
});
The response is null object;
But using advanced rest client i am getting the cookie value.Below is the screenshot.
Thanks for your time.
Note:All angular cdns are of version 1.5.8.