Subdomain session sharing? #433
Answered
by
francoism90
francoism90
asked this question in
Q&A
-
I would like to share the same session between (sub)domains:
The following tasks has been created to overrule the session domain: class SwitchDomainTask implements SwitchTenantTask
{
public function makeCurrent(Tenant $tenant): void
{
$this->setSessionCookie($tenant->domain);
}
public function forgetCurrent(): void
{
}
protected function setSessionCookie(string $domain): void
{
// Validate if subdomain
if (Str::substrCount($domain, '.') > 1) {
$domain = Str::after($domain, '.');
}
config(['session.domain' => ".{$domain}"]);
}
} However I'm aware this isn't the solution, the session/cache isn't shared between the tenants. It will result in invalid session(s) as it doesn't match the host. They are made to be run isolated from each other. What would be a solution/workaround? Is it possible to tell the subdomain it is sharing the same session as it's parent domain? Thanks! |
Beta Was this translation helpful? Give feedback.
Answered by
francoism90
Feb 3, 2023
Replies: 1 comment
-
Solved, see #372 |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
francoism90
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Solved, see #372