5

I'm using Angularjs in my project. I've set window.localStorage['foo'], but I need to use the data in other subdomains. For example, it starts on domain.com and goes to sub1.domain.com => sub2.domain.com.

So, when I try to use with the subdomains, I cannot access window.localStorage['foo'], and I need to set everything again.

Is there another way to do it?

Thanks

[ SOLUTION ]

I used ng-cookies and works good. angular/bower-angular-cookies

$cookies.put('myCookie', value, { domain: 'domain.com'} );

Thanks all answers!

user2918057
  • 189
  • 1
  • 12
  • 2
    This isn't an angular issue, this is an HTML5 issue. Local Storage in browsers is isolated by HTML5 Origin (scheme + hostname + unique port). In other words, `http://domain.com`, `https://domain.com`, `http://domain.com:5000`, `http://sub1.domain.com`, `https://sub1.domain.com`, etc. each have their own isolated storage. – Claies Dec 04 '15 at 00:14
  • @Steve while that is most definitely a duplicate discussion, I'm not sure that the answer is viable for the poster, as using an iframe in angular isn't really viable. I still don't think this is an angular issue specifically, or that there is a workable solution, but the duplicate feels a bit too generic. – Claies Dec 04 '15 at 00:37
  • 1
    Can you not just go old school and use a cookie? Otherwise consider a service call. – Cory Silva Dec 04 '15 at 02:48
  • it's not possible to post an answer (even a self answer) when a question is marked as a duplicate. – Claies Dec 04 '15 at 18:29

0 Answers0