felixdeimling
3 years ago

file-based sessions not working if "web" middleware assigned in Controller constructor

Posted 3 years ago by felixdeimling

I found out that sessions work if i register the routes and the middleware within a group

Route::group(['middleware' => ['web']], function () {
     Route::get('aktuell', "SeitenController@getAktuell");
     # other routes ...
});

But not if i assign the middleware in the Controllers constructor

function __construct()
{
     $this->middleware('web');
}

(which is my preffered way..)

works though by saving session explicitly via

$request->session()->put("test3",time()."-anna");
 $request->session()->save();

Please sign in or create an account to participate in this conversation.