0

I have an app written in Angular2+ and a CMS website hosted on a different subdomain. Once a user logs in, I want both subdomain to share his login info (to display "hello username" on the header, regardless of the system), so the user experience when moving between app/website will be transparent to the user.

One way to achieve this scenario is by hosting the webapp inside the CMS, however, probably not a good idea (this is currently how it's implemented)

Is there a better way to share session info?

Yuvals
  • 2,591
  • 4
  • 26
  • 49
  • You have tagged this question with `php session session-cookies`. Have you tried any of that? Because these are you answer. – rndus2r Sep 10 '17 at 07:46
  • You can [share cookies between the domain and the subdomains](https://stackoverflow.com/questions/18492576/share-cookie-between-subdomain-and-domain) and therefore if the session is set in a cookie you can share that too – apokryfos Sep 10 '17 at 07:46
  • only the app has a php backend, the website will be webflow hosted, without a real backend/session. I was thinking about localStorage, but not sure this is the best practice. – Yuvals Sep 10 '17 at 07:48
  • localStorage can be accessed by anyone, so no, this is not safe at all. You can append a session parameter to the url, so every call which is sent back to the backend can work with that. – rndus2r Sep 10 '17 at 09:08

0 Answers0