Session
I want to store a form value Inn session when I leaves a form(pages to other)
Well you should post the form to your page and store everything in the session. You can for example do that like so
public function store (Request $request)
{
$userId = auth()->id();
session()->put('form-' . $userId, $request->all());
return redirect()->route('some-route');
}
Now in your next method you can retrieve this session and return it to the view
public function nextAction()
{
$sessionData = session('form-' . auth()->id());
return view('some-view', compact('sessionData'));
}
That should be it!
A good alternative solution for this is using localStorage on the client side. This might be a good read for you: https://stackoverflow.com/questions/38930144/keep-input-value-after-refresh-page
@richard Great example! However if you refresh again, you will lose your data. It sounds to me that that is not a wanted case here!
Please or to participate in this conversation.