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

Lopsum's avatar

Laraval AJAX & Session

Hello ! I'm on Laravel 5.4 and I'm trying to make a multi-step form with AJAX. each step save the inputs in session and the last step save the records in database. To make that, I use different routes for each step :

Route::post('form/step-1', 'FormController@step1');
Route::post('form/step-2', 'FormController@step2');
Route::post('form/step-3', 'FormController@step3');
Route::post('form/step-4', 'FormController@step4');
Route::post('form/step-5', 'FormController@step5');

In my controller, I'm just doing this for each step :

public function step1 { RequestStep1Data $request) {
    Session::put($request->all());
    return response()->json();
}

When I move on the last step (step5), I'm loosing data session form previous step (not all, data from step 3 by exemple and no everytime) and I don't know why..... Please, can you help me ?

0 likes
1 reply
hypergalaktisch's avatar

Hello Vable, I've got a similar problem.

I'm using the dropzone to upload images in my multi step form. It's wired, when I push the images in my controller to the session, not all data are stored. It seems like the second image overrides the first because the request is the same, the third one works and so on. Did anyone have a good advise?

Please or to participate in this conversation.