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.
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.
I've created module for AngularJS to solve this issue:
https://github.com/stevermeister/ng-biscuit
now you can simply set options:
cookieStore.put('x', 5, {domain: 'youdomain.com'})
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With