Reputation: 810
I'm trying to display 404 page based upon user login, for which I'm trying to get the logged in user id from sessions.
But session session()->all()
always returns empty array and also auth()->id();
& Auth::id();
are also empty value.
Upvotes: 2
Views: 2133
Reputation: 1844
That's because in app/Http/Kernel.php
the protected $middleware
array doesn't have the middleware for the session.
What you can do is to move the \Illuminate\Session\Middleware\StartSession::class,
middleware from the web
middlware group to the global $middleware
array.
Upvotes: 7