Level 1
use Session;
public function prop_store(Request $request) {
$oldCart = Session::has('personal') ? Session::get('personal') : null;
}
Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.
I have a controller that saves user details into a session and it looks like this:
public function personal_store(Request $request){
$data = [
'name' => $request->name,
'email' => $request->email
];
Session::put('personal', $data);
return redirect('/listing/propdetails');
}
Now I have another controller, and it I want to access the name and email stored in the session.
public function prop_store(Request $request){
//here I want to show the name and the email
}
How can I access the name and email stored in the session?
public function prop_store(Request $request)
{
$data = session('personal');
echo sprintf('The name is %s and his email is %s', $data['name'], $data['email']);
}
Please or to participate in this conversation.