title: How to log a NOT existing user? - Laravel
body: <p>I need to log a user without creating it into the database. How can I do that?</p>
  
  <p>I'm using PHP 7.3, laravel 5.8 and Apache2.</p>
  
  <p>I tried this code (after reading <a href="https://laravel.com/docs/5.8/authentication#other-authentication-methods" rel="nofollow noreferrer">this</a>) :</p>
  
  <pre><code>$user = new \App\User();
  $user-&gt;password = \Hash::make("superpassword");
  $user-&gt;email = "email@email.com";
  $user-&gt;name = "Name";
  Auth::setUser( $user );
  Auth::login($user);
  
  if (Auth::check()) {
                  // the user is logged
                  $request-&gt;session()-&gt;regenerate();
                  $request-&gt;session()-&gt;put('key', 'value');
                  $request-&gt;session()-&gt;put('userData', $user);
                  $request-&gt;session()-&gt;regenerate();
                  $request-&gt;session()-&gt;put('redirectTo', '/home');
                  return redirect()-&gt;intended('/home');
  }
  </code></pre>
  
  <p>After that, I made a redirect and the user seems not logged anymore.</p>
  
  <p>I expect to find a way to log this user without creating it into the database. In the default login page, it must success.</p>
  
  <p>(Sorry for my bad english, I hope I was clear)</p>