Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

Walker's avatar

Save form data to session

Hi, what is the best way if I want to save the data from the request (form) to a session for further use?

0 likes
1 reply
Braunson's avatar
Braunson
Best Answer
Level 18

session()->put('foo' $request->all());

Saves your request (array) to the foo variable in the session.

You can also use this on the $request variable..

$request->session()->put('foo', $request->all())

If you don't have access to $request for whatever reason you can use the helper request() in it's place.

Please or to participate in this conversation.