> For the complete documentation index, see [llms.txt](https://developers.memberspace.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://developers.memberspace.com/getting-started/install-code/multi-subdomain-site.md).

# Multi-subdomain site

In case your site spreads multiple subdomains, like:

* yoursite.com (or [www.yoursite.com](http://www.yoursite.com))
* blog.yoursite.com
* docs.yoursite.com
* etc.

you can tie these subdomains together. This means if a member logs in/out at any of the subdomains, they will be logged in/out at all of them.<br>

{% hint style="success" %}
The MemberSpace widget normally uses LocalStorage to persist information across visits / refreshes. While LocalStorage is the preferred way of storing things, it cannot be accessed in a cross-subdomain manner.&#x20;

For this reason, if the above feature is in use, the widget persists authentication data (a subset of all persisted information) in Cookies instead.
{% endhint %}

{% hint style="warning" %}
While Cookies can be accessed in a cross-subdomain manner, because of privacy and tracking prevention reasons, browsers regularly introduce new limitations and blocks on them.

For this reason, this multi-subdomain login feature can stop working for a subset of browsers at any time and without prior notice. (I.e., members on the latest Chrome / Safari / / Edge / Firefox version not being able to log in)
{% endhint %}

To enable this feature you have to edit the configuration part of your install code as follows

```javascript
var MemberSpace = window.MemberSpace || {
  subdomain: "YOUR_SUBDOMAIN",
  cookieDomain: "BASE_DOMAIN"
};
```

{% hint style="info" %}
The value of `cookieDomain` has to be the top level domain that you own. In the above example this would be `yoursite.com`\
\
Make sure that you replace `YOUR_SUBDOMAIN` and `BASE_DOMAIN` with the appropriate values.

\
Make sure that all instances of the install code are updated across all subdomains of the site you want to connect together.
{% endhint %}

{% hint style="warning" %}
Any time you change the `cookieDomain` value, all users currently logged in to the site may be logged out, requiring them to log back in.
{% endhint %}
