Im doing a new project and i want the separate front and backend completely so theoretically anyone can build his own frontend by interacting with the api backend or even just machine to machine interaction.
this is fine for single requests but since an api is stateless but i was wondering how to handle data that has to be cut up in steps.
For example a really long form that spans several pages/ chapters.
With just old school php application you'd simply store the data from each page into session and after filling out all of the single pages successfully you'd store the entire session into the database.
But this is going to be a problem when working with api request because it doesnt use sessions.. its stateless.
Sure you could just save all data in session anyway on the frontend and then post the entire session to the api endpoint but what if the api returns a validation error for some reason because it got a stricter validation rule for a form-field that was already validated on page 1 on the frontend?
from the user point of view it would be very strange if at that point, after supposedly everything was correctly filled out the page still gets redirected back to the first page with a message that suddenly something was not filled out correctly after all.
i guess the problem at hand is clear so my question is, how to handle/ setup something like this.
Are there common practices to solve this? Or perhaps it's just a really bad idea to even want to go this way?
what are your thoughts?