Cannot get logged in user on a subdomain

Hello,

I have webflow website integrated with memberstack running on a example.com.
I also have a another application on test.example.com
and on that sub-domain I try to get user logged in on example.com

I include this
<script src=“https://api.memberstack.io/static/memberstack.js?webflow” data-memberstack-id="…"
Into a head.

And try todo this:

MemberStack.onReady.then(function(member) {
    console.log('member', member);
});

but I do not get user, I get an object with loggedIn: false attribute.

I can see ‘memberstack’ cookie shared to test.example.com.

Also POST request to https://api.memberstack.io/site/settings is being made from a test.example.com,
but it does not return user details.

Please advice.

Thank you.

Hi Justinas!

You can login on example.com and will access to sub.example.com. That said, currently it doesn’t work in the other direction.

Logging in on sub.example.com will not give you access to example.com. It’s crazy how cookies work :sweat_smile:

It is on my list though to change the way to set cookies so it will work either way. I don’t have an eta on that though.

Hi, thanks for you reply.
Sorry, maybe I did not explain this clear enaugh. Its not other way. Webflow + memberstack is running on example.com. Custom app is on sub.example.com.
memberstack cookie is present on sub.example.com and still cannot get logged in user:)

Thank you.

Hi Justinas, quick clarifying q:

Are your sign up and login pages on example.com or sub.example.com?

Hi,

Sign up and login is on example.com

Thanks.

1 Like

I think that’s the source of the problem. Memberstack can’t pass cookies from one domain to another, so sub.example.com is unaware if a member logs in on example.com.

If you move your signup and login forms to sub.example.com it should start working.

We had to do something similar on memberstack.io and app.memberstack.io/signup. It’s considered a “best practice” since each browser treats cookies differently.

Cookies can be passed to a subdomain and it is (memberstack and fcsid) are passed to sub.example.com

1 Like

Nice! But the login still isn’t working?

If that’s the case, I do still recommend moving your signup/login pages to the parent domain.