# Can I share local storage between domain and sub-domain?

**URL:** <https://community.weweb.io/t/can-i-share-local-storage-between-domain-and-sub-domain/17408>\
**Category:** Ask us anything\
**Created:** [March 24, 2025, 7:46am UTC](https://community.weweb.io/t/can-i-share-local-storage-between-domain-and-sub-domain/17408 "2025-03-24T07:46:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kdjamo](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kdjamo](https://community.weweb.io/u/kdjamo)\
**Post date:** [March 24, 2025, 7:46am UTC](https://community.weweb.io/t/can-i-share-local-storage-between-domain-and-sub-domain/17408/1 "2025-03-24T07:46:51Z")

</div>

Hello,  
I hope to design 2 projects where one is the domain and the other is a sub-domain. I want to share a tokens between a domain and sub-domain for authentication purposes  
**[mydomain.com](http://mydomain.com/)** as the **main page** with **login screen**

Then have a separate project with a sub domain.

- **[academy.mydomain.com](http://academy.mydomain.com/)**

Can I use Local storage or similar way to easily share this token data?

---

<div class="post-metadata">

**Author:** ![Broberto](https://sea2.discourse-cdn.com/flex016/user_avatar/community.weweb.io/broberto/32/5918_2.png) [@Broberto](https://community.weweb.io/u/Broberto)\
**Post date:** [March 24, 2025, 8:53am UTC](https://community.weweb.io/t/can-i-share-local-storage-between-domain-and-sub-domain/17408/2 "2025-03-24T08:53:40Z")

</div>

Nope, local storage is bound to a domain. There is a workaround but it’s not pretty.

> <https://stackoverflow.com/questions/4026479/use-localstorage-across-subdomains>

---

<div class="post-metadata">

**Author:** ![kdjamo](https://avatars.discourse-cdn.com/v4/letter/k/45deac/32.png) [@kdjamo](https://community.weweb.io/u/kdjamo)\
**Post date:** [March 24, 2025, 9:04pm UTC](https://community.weweb.io/t/can-i-share-local-storage-between-domain-and-sub-domain/17408/3 "2025-03-24T21:04:54Z")

</div>

Thanks for that one.  
The main reasoning to use sub-domains as separate projects is to reduce the risk of affecting another part of the website when working on different parts.  
So my thoughts are:  
When a user logs in at [mydomain.com](http://mydomain.com) and then moves to [academy.mydomain.com](http://academy.mydomain.com), essential information will be passed via a query string. The sub-domain will then call a Xano API to retrieve any additional data it needs and store it in local storage.  
I think that will do the job for my requirements  
Hope that makes sense!
