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

hasanhatem's avatar

Cookies or URL Parameters to save data from previous page?

Hello,

I have multi page registration page,

So the user start when he select the plan, after that his goal and other things

  1. Plan Type.
  2. Plan duration.
  3. His Goal.
  4. Some data like: his weight, age , tall, etc...
  5. The user will selects some meals for his plan.
  6. registration form.

so i need to collect all these data until he reach to register form and finish the registration. after that i can insert all the data in database.

What is the best way to save all that data? is it the Cookies or in url Parameters? in laravel 8?

Thanks.

0 likes
4 replies
johnDoe220's avatar
Level 8

best way use session

session()->put('key', 'value');

store multi data into session

session()->put(['key'=> 'value', 'key2' => 'value2']);

get session

session()->get('key')

forget session

session()->forget('key');

It will definitely help you

https://laraquiz.com/
1 like
johnDoe220's avatar

Yes sure,for example

$posts = Post::all();
session()->put('posts', $posts);
dd(session()->get('posts'));
1 like

Please or to participate in this conversation.