You are going to struggle if you keep the ID in a session, very much so with the problems you have suggested.
You could maybe look into using the window.unloadto fire an ajax request that will clear the session, only anything but a next click - but tbh, I am not sure how reliable that would be.
Personally, for a multistep form, I would use something like https://binarcode.github.io/vue-form-wizard/#/ so the form is all within a single page, and just shown/hidden dependant on the step.
If you wanted to persist after each step, you could still fire the ajax request, and then just store the resultant ID in the hidden field and/or a JS variable, to pass along with the next request.
Another option, would be to pass the id via a querystring/post to the next page, but you would need to validate this against the user before continuing, and also if not present, they would have to be redirected back to the first step.