Angular.js: ngCookies - $cookies doen't use defaults set on $cookiesProvider

Created on 11 Jun 2015  路  2Comments  路  Source: angular/angular.js

Please see this Plunker for an example:

http://plnkr.co/edit/pGWnxDToIDcI4BTDkH1l?p=preview

I inject '$cookiesProvider' into a .config() call and set a path:

$cookiesProvider.defaults = { path: '/invalid-path' };

But new cookies created with $cookies.put() do not use that path and are set/can be read.

Passing the same path into another $cookies.put() call correctly uses the path and the cookies is not created/can't be read.

Most helpful comment

You have to change the object in-place. Eg. $cookiesProvider.defaults.path = '/invalid-path';

All 2 comments

You have to change the object in-place. Eg. $cookiesProvider.defaults.path = '/invalid-path';

Ah, great - I suspected I was doing something wrong but we couldn't figure it out in #angularjs yesterday. Thanks for the answer.

Was this page helpful?
0 / 5 - 0 ratings