Multi-subdomain site

In case your site spreads multiple subdomains, like:

  • yoursite.com (or 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.

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.

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

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)

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

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

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.

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.

Last updated