how to retrieve session data in constructor method in laravel?

Asked 4 years ago Modified 21 hours ago 2694 Views
0
Anonymous Post Date: Jun 23, 2021

Answers (1)

1

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.

Jiwan Thapa Answered: Jun 24, 2021
Comments

Sign in to help the community by answering this question.

Log In to Answer