@martinzeltin What I did to solve this was create a middleware to override the config at runtime depending on domain match. Then I was sure to use the middleware priority in the kernal to run my middleware before start session.
Middleware
class SessionDomains
{
/**
* Handle an incoming request.
*
* @param Request $request
* @param Closure $next
* @return mixed
*/
public function handle($request, Closure $next)
{
if($request->getHost() === 'best4games.com'){
config([
'session.domain' => '.best4games.com'
]);
}
return $next($request);
}
}
and in the http Kernal.php, add it at the top of your web middleware group:
protected $middlewareGroups = [
'web' => [
SessionDomains::class,
],
];
and above start session in priority group
protected $middlewarePriority = [
SessionDomains::class,
StartSession::class,
ShareErrorsFromSession::class,
Authenticate::class,
ThrottleRequests::class,
AuthenticateSession::class,
SubstituteBindings::class,
Authorize::class,
];