Anonymous
23 Jun, 2021

How to retrieve session data in constructor method in laravel?

1 Answer         1559 Views

Jiwan Thapa
24 Jun, 2021

It's quite easy to retrieve session in laravel constructor. All you need to do is move these two lines

\Illuminate\Session\Middleware\StartSession::class,

\Illuminate\View\Middleware\ShareErrorsFromSession::class,

from your protected $middlewareGroups = [] array to your protected $middleware= [ ] array in your App\Http\kernel.php.

Once you move these lines, you can easily retrieve session in your constructor.


1 Like         0 Dislike         0 Comment        


Leave a comment