AngularJS $http and cookies
Using AngularJS and trying to set a cookie on the back-end?
1. Add withCredentials: true config param.
2. Set Access-Control-Allow-Credentials header to true.
3. Specify Access-Control-Allow-Origin header on the server. It can only be set to one value for CORS requests, so if you want to allow many sources, you should get the Origin request header, compare it to the array of your desired sources (see appendix), and, if it’s found there, set the …-Allow-Origin header to match your origin.
4. When setting the cookie, mark httponly as true.
5. Don’t set the cookie’s domain on localhost.
Appendix: Working on localhost? Remember that ports are important too.
Update 1: You can set withCredentials to true as default by injecting $httpProvider in your module's run function: $httpProvider.defaults.withCredentials = true;






