$httpProvider.defaults.withCredentials = true;
Whether to set the withCredentials flag on the XHR(XMLHttpRequest) object.
If you use the standard $http service to access remote APIs, it will Just Work as long as the server is configured to allow requests from your domain and you don’t need to store cookies.
But for many applications, we also need to set and store cookie information for things like logins. By default this is not allowed in most browsers and you’ll be smashing your head wondering why the cookie information isn’t being saved!
Enter: withCredentials. withCredentials is a flag set on a low-level XMLHttpRequest (AJAX) object, but in Angular we can configure our $http requests to set this flag for everything by doing:
angular.module('myApp')
.config(['$httpProvider', function($httpProvider) {
$httpProvider.defaults.withCredentials = true;
}])