I'm using sessions for the first time in Laravel and I'm trying to do a multiple step form, so I thought using sessions would be a smart move. however the following code returns a null value, what am I doing wrong?
$user_information = [
"name" => $request->name,
"email" => $request->email,
"remember_token" => $request->_token,
"password" => bcrypt($request->password),
"role_id" => 3
];
session('user_signup', $user_information);
dd(session('user_signup'));
In your controller you can save variable into session like
session()->put('user_signup',$user_information);
For checking your session variable in controller
session()->has('user_signup','default value');
For deleting your session variable in controller
session()->forget('user_signup');
For checking your session variable if it exists in blade and printing it out
@if(session()->has('user_signup'))
session()->get('user_signup')
@endif
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With