Handling Laravel callback() exceptions: "Invalid state" and "Can't initialize a new session while there is one activ..."

Anyone find a good solution to this? I’m running into the Core Exception: Invalid State quite often myself. I can’t for the life of me track down exactly whats happening or why.

I found that when users try to hit the login endpoint when they’re already logged in, it throws a Invalid State error, so checking before redirecting to Auth0 fixes that. I chalk it up to users bookmarking the login endpoint and using the bookmark to get to the app.

    public function login()
    {
        if ( Auth::check() ) {
            return redirect()->route('home');
        }

        $authorize_params = [
            'scope' => 'openid profile email',
        ];

        return \App::make('auth0')->login(null, null, $authorize_params);
    }

That fixed a number of the Invalid States, but there’s still far to many.