Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

iamlux20's avatar

Parent-Child Laravel Projects, keep the same Auth session

Hi, as title suggests, is there a way to login to the child project if parent project is logged in? Looking to optimize my code since it's shoddy as it is.

On Parent project, I have this link to the child project

// Parent Project Blade: 
<a href="http://child-project.test/authenticate/{{ auth()->user()->email }}"> Access Child Site </a> //GET request to child-project

// Child's Authenticate Function:
    public function auth(Request $req)
    {
        $user = User::where('email', $req->email)->first();
        Auth::login($user);
        return redirect('/');
    }

This is currently on a GET request, if I can use redirect() with POST that would be better. Or if I can skip the authentication on the child project and just use parent's session.

0 likes
3 replies

Please or to participate in this conversation.