Auth::user() returns null in Laravel 5.2

前端 未结 4 808

I have searched and found various results like these: auth()->user() is null in Laravel 5.2 and Auth::user() returns null

But, mine is still not working.

4条回答
  •  天命终不由人
    2021-01-06 10:42

    Thank you guys.

    The problem solved here: https://laracasts.com/discuss/channels/laravel/authuser-returns-null-in-laravel-52

    I had to add the stack into middleware directly (not in the group).

    in /Http/kernel.php:

    protected $middleware = [
        \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class
    ];
    

提交回复
热议问题