In new laravel I can\'t get session in constructor. Why?
public function __construct()
{
dd(Session::all()); //this is empty array
}
a
As of other answers no out of the box solution for it. But you still can access it using Middleware in constructor.
So here is another hack
public function __construct(){
//No session access from constructor work arround
$this->middleware(function ($request, $next){
$user_id = session('user_id');
return $next($request);
});
}