: Prevent form resubmit after Browser Back button click In the early days of the web it was a problem that clicking the browser's Back button after clicking Submit could cause the form to be
In the early days of the web it was a problem that clicking the browser's Back button after clicking Submit could cause the form to be resubmitted so one might, for instance, end up with a double purchase.
This does not seem to be a problem any longer. How was it fixed? Do individual sites have to work around this or did browsers change?
More posts by @Candy875
2 Comments
Sorted by latest first Latest Oldest Best
One way to prevent this is to use the POST/Redirect/GET pattern.
Instead of directly sending a 200 after receiving the POST request, the server sends a 303 (or 302) redirect instead. The client follows it and gets (via GET) a 200 then. Refreshing this page repeats the last GET, not the previous POST.
For implementation questions, see the Stack Overflow tag "post-redirect-get".
I've used a javascript POST of the form data followed by a js re-direct. Using the back button doesn't cause those forums to be re-submitted.
Terms of Use Create Support ticket Your support tickets Stock Market News! © vmapp.org2024 All Rights reserved.