Back

share session between multiple sites

  • 0
  • Users
  • Accounts
  • Web
Zeke(Jafesu)
27 Aug, 2023, 19:46

I have 2 different websites using the same appwrite project, and accounts. Is there anyway to SSO between them? They are both running on vue, I just don't want to have to log in to both sites separately.

TL;DR
To share sessions between multiple sites, you can use the same Appwrite endpoint, but the sites should have the same base domain for the cookie to be first-party. However, this may not work in practice. An alternative approach would be to use OAuth to avoid having users enter their password again. Subdomains do matter as cookies are attached to the domain, not the app using it. If it's a third-party cookie, it might be blocked. You can try using the `.getAccount()` function to retrieve the cookie data saved from one endpoint on another. Make sure it's the same browser. If the endpoint is the same, the
Drake
27 Aug, 2023, 23:23

Same endpoint? If so, the browser would have the cookie that authenticated the user...but you might run into a 3rd party cookie problem 🧐

Zeke(Jafesu)
29 Aug, 2023, 01:33

Sorry just saw your response, yes same browser

Drake
29 Aug, 2023, 01:34

Ya so it could work

Zeke(Jafesu)
29 Aug, 2023, 01:35

so the .getAccount() should pull the cookie data that is saved from one endpoint on another?

Drake
29 Aug, 2023, 01:48

Yes because cookies are attached to the domain not the app that uses it. That said, if it's a 3rd party cookie, it might be blocked

Zeke(Jafesu)
29 Aug, 2023, 05:24

Does subdomain matter? Like login on x.example.com and try to share the login on y.example.com

Drake
29 Aug, 2023, 16:58

You would need to use the same Appwrite endpoint so that the cookie is shared. But you apps would need to have the same base domain to make the cookie 1st party...so that might not actually work out.

Using oauth might be the best approach so that they don't need to put in their password again

Reply

Reply to this thread by joining our Discord

Reply on Discord

Need support?

Join our Discord

Get community support by joining our Discord server.

Join Discord

Get premium support

Join Appwrite Pro and get email support from our team.

Learn more