More powerful $cookies service
I want to set a cookie on the root path / so it's available everywhere on the domain.
But the $cookies service only accepts name and value, and always sets the cookie path to the current page via self.baseHref().
Could the $cookies service be extended to provide access to additional cookie properties like path, expires, domain and secure?
I quite like the API of the jquery.cookie plugin: https://github.com/carhartl/jquery-cookie#usage. It keeps the common name=value use case simple and allows to set additional cookie properties via a third options object parameter.
I'm not very proficient in Javascript but I might try to implement something over the weekend.
Working on this (first version, I'm not worried about providing jquery's "raw" option), just updating tests now.
branch is here: https://github.com/jzacsh/angular.js/compare/master...issue950_cookies
Hey, sorry I forgot to update this thread. Switched teams and don't have the time do this. Someone should take this on :-)
any updates on this?
+1 for updates and a resolution
+1 Not supporting secure cookies is a security issue and should be addressed ASAP.
Just added a $200 bounty to this issue: https://www.bountysource.com/issues/68135-more-powerful-cookies-service
+1
you could always use a different library like: https://github.com/grevory/angular-local-storage
Would it not be possible to simply replace the existing code for cookie control with a third-party library like jQuery Cookie https://github.com/carhartl/jquery-cookie
This plugin provides support for custom expiry dates, domain names (set example.com from sub.example.com etc), path values, and secure cookies, thus:
$.cookie('cookiename', 'cookievalue', { expires: 7, path: '/', domain: 'example.com', secure: true });
Although local-storage and jQuery both provide workarounds, this ticket is for fixing the core issue within AngularJS so workarounds aren't necessary.
angular-cookies is no longer 'core'. its more of a Angular team supported plugin now.
+1
+1 - for reference this seems to work pretty well - https://github.com/ivpusic/angular-cookie - but I still think this should be part of the included Angular cookie plugin.
+1
+1 We were just bitten by this, with cookies being shared between different environments running on the same host but different ports.
The current implementation is dangerous IMO, as it makes it impossible to properly secure cookies you create. This is going to lead to Angular apps which are vulnerable to XSS attacks.
+1 what is the current status?
+1 I'd like to be able to set path, expiry and domain
:+1:
+1
+1 any update?
I want to use $cookieStore to store data that can be read by javascript running on any of my products subdomains (lasvegas.x.com, losangeles.x.com)
+1