PHP会话和浏览器缓存的页面

I have a multipage form and I track the position of of the user across different pages with $_SESSION['current_page'] which is going to be reinitialised with every new page

<?php // page1.php

$current_page = 1;

$_SESSION['current_page'] = $current_page;

...

?>

I use $_SESSION['current_page'] to correctly process the submission of each form and redirect to the next page. Yet this solution stops working if the user hit the go-backwards button on her browser when she is, for example, on page 2: she will be moved to the cached version of page 1 and yet the value stored with $_SESSION['current_page'] will be 2. Then if the user hits the submit button on the cached page 1, she will be redirected to page 3.

That is often the problem with multi-page forms.

A solution I would consider is to have a wizard-type form, so that everything happens locally, and the server only gets the data when the whole form is completed.

This one would work well (if you are using Bootstrap). http://getfuelux.com/javascript.html#wizard