title: Laravel 8 - Auth::login() do not save $user data on session
body: <p>My stack:</p>
  <ul>
  <li>Laravel 8</li>
  <li>PHP 7.4</li>
  <li>DoctrineORM</li>
  <li>LDAP Auth</li>
  </ul>
  <p>I'm trying to do a manual authentication on Laravel (Laravel 8).</p>
  <p>But, when I try to save a <code>$user</code> variable in Auth, it is not saved.</p>
  <p>Login Controller:</p>
  <pre><code>public function auth(LoginRequest $request)
      {
          $auth = Adldap::auth()-&gt;attempt($request-&gt;user.env('LDAP_USER_SUFIX'), $request-&gt;password, true);
          if($auth){
              $userData = Ldap::ldapUserAttributes($request-&gt;user);
              $user = new User($userData['name'], $userData['mail']);
              Auth::login($user);
              return redirect()-&gt;route('dashboard');
          }
          return redirect()-&gt;back()-&gt;withErrors('Usuário e/ou senha incorretos');
      }
  </code></pre>
  <p>The User class implements the Authenticatable, but it isn't a database entity.</p>
  <p>These are my routes (<code>web.php</code>):</p>
  <pre><code>
  Route::get ('/login',                               [Login::class, 'index'])                                        -&gt;name('login');
  Route::post('/login',                               [Login::class, 'auth'])                                         -&gt;name('auth');
  
  Route::middleware(['auth'])-&gt;group(function () {
      Route::get('/dashboard', [Dashboard::class, 'index'])-&gt;name('dashboard');
  });
  </code></pre>
  <p>If I remove the authentication middleware and print what it receives, NULL is printed.</p>
  <p>But, if I print Auth content right after <code>Auth::login($user);</code> at Login Controller, the User data is printed on screen.</p>
  <p>This is my User implementation:</p>
  <pre><code>&lt;?php
  
  namespace App\Models;
  
  use Illuminate\Contracts\Auth\Authenticatable;
  
  class User implements Authenticatable
  {
      private $cpf;
      private $username;
      private $email;
      private $senha;
      private $remember_token;
  
      public function __construct(string $cpf, string $username, string $email)
      {
          $this-&gt;cpf = $cpf;
          $this-&gt;username = $username;
          $this-&gt;email = $email;
      }
  
      public function getUsername()
      {
          return $this-&gt;username;
      }
  
      public function getEmail()
      {
          return $this-&gt;email;
      }
  
      public function getCpf()
      {
          return $this-&gt;cpf;
      }
  
      public function getAuthIdentifierName()
      {
          return $this-&gt;username;
      }
  
      public function getAuthIdentifier()
      {
          return $this-&gt;cpf;
      }
  
      public function getAuthPassword()
      {
          return $this-&gt;senha;
      }
  
      public function getRememberToken()
      {
          return $this-&gt;remember_token;
      }
  
      public function setRememberToken($value)
      {
          $this-&gt;remember_token = $value;
      }
  
      public function getRememberTokenName()
      {
          return $this-&gt;remember_token;
      }
  }
  
  </code></pre>
  <p>PS.: <code>Session::set('test', 'test');</code> and <code>Session::get('test')</code> work for me in diferents routes.</p>
  <p><code>$middlewareGroups</code> in the Kernel.php</p>
  <pre><code> protected $middlewareGroups = [
          'web' =&gt; [
              \App\Http\Middleware\EncryptCookies::class,
              \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
              \Illuminate\Session\Middleware\StartSession::class,
              // \Illuminate\Session\Middleware\AuthenticateSession::class,
              \Illuminate\View\Middleware\ShareErrorsFromSession::class,
              \App\Http\Middleware\VerifyCsrfToken::class,
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
  
          'api' =&gt; [
              'throttle:api',
              \Illuminate\Routing\Middleware\SubstituteBindings::class,
          ],
      ];
  </code></pre>
  <p>My Session is set to save in file</p>