I have the following 4 sub-domains for my project:
www.mysite.com
- public site, published pages
etc.
my.mysite.com
- normal users log in to this domain to create pages
and other stuff
company.mysite.com
- Company
hasMany
Employees
that log in to this sub-domain to manage their pages
and other stuff
admin.mysite.com
- Admin
s of the site log in here to manage everything
--
Typically, I want to keep all 4 sub-domains separate. So a user logged in to my.
should not be able to view company.
unless they login their as well. I have managed to do this by creating the following middlewares:
auth:my
auth:company
auth:admin
Using the above I have different login views/routes etc. for the different types of users working correctly.
--
I needed a way to share sessions across the subdomains because when a user creates a Page
on the my.
, they can publish it and it shows on the public www.
(www.mysite.com/my-page
)
What I needed is that when the User
who owns the Page
and is logged in to my.
, visits their own page on the www.
sub-domain, an Edit
button to show.
I managed to do this by sharing sessions across my subdomains by making the following change:
config/session.php
domain => env('SESSION_DOMAIN', '.mysite.com')
--
However, this messes up the logins for company.
and admin.
, because when a User
logs in to my.
, the session is shared across the sub-domains.
How do I share the sessions across the sub-domains but group them so something like:
domain => [
['www.mysite.com', 'my.mysite.com'],
['www.mysite.com', 'company.mysite.com'],
['www.mysite.com', 'admin.mysite.com'],
]