Hi everyone.
For the last few days I've been trying to implement a subdomain redirect with login in. So far I haven't been able to get it working :(.
What I'm trying to achieve here is to login in the www.example.com and if the user is valid and has a registered domain, redirect him (logged in) to it, for example to test.example.com.
So far I've been able to redirect the user to the subdomain correctly but I cannot make it arrive logged in.
I've been trying different approach one of them is to resend the login form to the subdomain to force the system to login him again. (I leave a bit of code as I was trying it, might not be perfect was a prove of concept that miserably failed)
Any suggestion or help would be really appreciate it. Thx in advance.
if(Session::get('company_subdomain') == "www" || Session::get('company_subdomain') == null){
//lets find the user subdomain and redirect him to it, logged in
return redirect()->intended("https://" . $user->client->wildcard_sub . Config::get('app.domain') . $this->loginPath)->withInput();
Auth::attempt(['email' => $request->email, 'password' => $request->password]);
return redirect()
->to("https://" . $user->client->wildcard_sub . Config::get('app.domain') . $this->loginPath)
->with('email', $request->email)
->with('password', $request->password);
Apparently I'm not the first one to try this (https://laracasts.com/discuss/channels/general-discussion/subdomain-session-on-log-in) @username , but there is still no answer to it.