I have a newly installed laravel application (version 8.36.2) and the session storing is not working, is it a release issue?
I made my code step-by-step by the laravel documentation, and the stored session is lost, if i open a new route. For example.:
My base controller.:
public function setSession(Request $req)
{
$req->session()->put('name', 'Jennifer');
echo "Saved";
}
public function getSession(Request $req)
{
if ($req->session()->has('name')) {
echo $req->session()->get('name');
} else {
echo "Empty the session";
}
}
My web.php
Route::get('set-session', [LoginController::class, 'setSession'])->name('session.set');
Route::get('get-session', [LoginController::class, 'getSession'])->name('session.get');
The storing is working, so if i dd() the session after the setSession() I can see the name property, but, if I open the /get-session route, the name session property is null.
I also tryed with the session(['name' => Jennifer]) facade, but it also doesn't work.
Can someone help me, why?