1

in Angular 6, when I stored the data in local storage (localhost:4200) but when we can run a subdomain like(abc.localhost:4200) that time data removed in local storage please help me out this problem

Mehul Patel
  • 21
  • 1
  • 3

3 Answers3

1

You can use Cross Storage or Cross DomainStorage npms

Shubham Sharma
  • 613
  • 6
  • 14
0

In short. No.

This is the definition of localStorage specification. As Mozilla said;

The read-only localStorage property allows you to access a Storage object for the Document's origin;

and there are some examples of what is Document origin.

Serhan C.
  • 1,152
  • 1
  • 12
  • 10
-2

Data stored to domain.com can not be accessed from sub.domain.com as per the standards. So you cant access local storage of localhost:4200 from abc.localhost:4200 no matter what you do. But to overcome this you may use solutions suggested by these posts,

https://jcubic.wordpress.com/2014/06/20/cross-domain-localstorage/

Can HTML5 databases and localStorage be shared across subdomains?

use localStorage across subdomains

Srinivasan Sekar
  • 2,049
  • 13
  • 22