I am redirecting the page after a successful login check and the session is created but the session is not available after page redirection.
My Login Controller:
$validated = $request->validate([
'email' => 'required|email',
'password' => 'required',
'g-recaptcha-response' =>'required|captcha',
],
[
"g-recaptcha-response.required" => "Captcha is required!",
]);
if(usernamd and password matches){
session()->put("username",$username);
return redirect()->route('home');
}else{
return Redirect::to("/login")->withFail('Wrong Passoword entered.');
}
if I print the session variables, they are visible and have proper values, but when it is redirected to the home page, the session variables are not set. session()->all() is showing empty array.