Can't initialize a new session while there is one active session already

Please include the following information in your post:

  • Which SDK this is regarding: e.g. auth0-laravel
  • SDK Version: e.g. auth0/login
  • Platform Version: e.g. Laravel 8
  • Code Snippets/Error Messages/Supporting Details/Screenshots:

Can’t initialize a new session while there is one active session already

I got this error when I am trying to implement using laravel SDK.

//Callback method 
public function callback()
    {
        // Get a handle of the Auth0 service (we don't know if it has an alias)
        $service = \App::make('auth0');

        // Try to get the user information
        $profile = $service->getUser();

        // Get the user related to the profile
        $auth0User = $profile ? $this->userRepository->getUserByUserInfo($profile) : null;

        if ($auth0User) {
            // If we have a user, we are going to log them in, but if
            // there is an onLogin defined we need to allow the Laravel developer
            // to implement the user as they want an also let them store it.
            if ($service->hasOnLogin()) {
                $user = $service->callOnLogin($auth0User);
            } else {
                // If not, the user will be fine
                $user = $auth0User;
            }

            \Auth::login($user, $service->rememberUser());
        }

        // echo "<pre>"; print_r($auth0User); die();

        return \Redirect::intended('/');
    }


//custom auth controller login method
public function login()
    {
        // echo "<pre>"; print_r(Auth::user()); die();
        if (Auth::check()) {
            return redirect()->intended('/');
        }

        return App::make('auth0')->login(
            null,
            null,
            ['scope' => 'openid profile email offline_access'],
            'code'
        );
    }

``````