Not sure why its not behaving as it should. May be code snippets might be really helpful here. But by the above linked example in the OP. The reason its not working there is :
- There are 2 domains : eskimo.dev & eskimo.ooo (Both of these are different). When the first domain eskimo.dev is opened, the local storage is set in the browser with reference to eskimo.dev and this will accessible to page with origin "eskimo.dev".
- But when eskimo.ooo is opened (domain that has the iframe src set to eskimo.dev) here the localStorage will not be shared as the origin domain is eskimo.ooo, and therefore cannot access localStorage data of eskimo.dev .
What will work ? :
- If you were to have eskimo.dev/localStorage (where the localStorage is set in the browser) and
- now if you open eskimo.dev/localStorage/iframe (in which the iframe src points to eskimo.dev/localStorage, this page will have access to localStorage data.), why ?
Because, the domain origin is not changing, hence it can access the same localStorage.
Thanks