Views and session variables available in sub domains

1

I'm creating a laravel web system where multiple sub domains will be created to find some services for users. Ex. Panel.domain.com, store.domain.com, etc.

My question is:

  • My variables created in the main domain session will be accessible to all sub domains?
  • You can manage the entire application in the domain main providing views via routes to sub domains?
asked by anonymous 06.04.2018 / 04:51

1 answer

1

It is not possible to share the native PHP session because they are different domains. In this case you will have to use a session control via Database or another data source that is commonly accessible between all domains (main + subdomains) and take the authentication from one domain to another through variables linked to the HTTP request, either via GET, POST or HEADER.

A Token system will also help you in this. Where each session created by a user generates a token, which will be stored in this common data source, and when you take the user to another domain, you attach that token to the request, as informed above, and do the validation of the token in the request received in the new domain.

    
06.04.2018 / 16:40