how to set domain for angularJS $cookies
angularjs, cookies
Solution
Currently this is not implemented in angular (1.2.7). You may have a look at angular.js line 4348 - the relevant code a little bit reduced:
if (value === undefined) {
// Delete the cookie
rawDocument.cookie = escape(name) +
"=;path=" + cookiePath + ";expires=Thu, 01 Jan 1970 00:00:00 GMT";
} else {
// set or update the cookie value
rawDocument.cookie = escape(name) + '=' + escape(value) + ';path=' + cookiePath);
}
as you can see the ;domain=XYZ is not included. You have to write your own cookiestore that implements this feature - but this should be very easy.
Problem
It seems $cookies only allows to set the Key/Value pair. But i need to set the domain parameter as well. I need to set the cookie from one subdomain of website and use it from all subdomains of website. I am using the angularJS and Twitter Bootstrap.