1

Currently I am implementing angular cookies to retain information. This is the way I add information. oItems is the javascript array of objects.

Angular Versoin 1.4.7

$cookies.putObject("oItems",oItems,[{path:'/',expires:exp,domain:'alpha.domain.com'}])

And the way to get is :

$cookies.getObject("oItems")

These work fine when I am on url alpha.domain.com

Now I try to access cookie at alpha.domain.com/cart and able to receive values. The problem comes when I remove element from array "oItem" On alpha.domain.com/cart it shows one item only where as on alpha.domain.com it shows 2 items .

Can you guys please tell me which could be the issue?

Sandeep Poonia
  • 2,158
  • 3
  • 16
  • 29
89n3ur0n
  • 921
  • 11
  • 24

1 Answers1

1

Basically the answer is to set path to "/" so that all actions/urls from your application access and update the same cookie. Simply we have to do:

myApp.config(['$cookiesProvider',function ($cookiesProvider) {
$cookiesProvider.defaults.path = '/'; }]);

It took me find to do so but yes, it works.

89n3ur0n
  • 921
  • 11
  • 24