Beefy Boxes and Bandwidth Generously Provided by pair Networks
Welcome to the Monastery
 
PerlMonks  

Re: How to prevent a Reload from resubmitting a form?

by sundialsvc4 (Abbot)
on Jul 08, 2013 at 14:13 UTC ( #1043128=note: print w/ replies, xml ) Need Help??


in reply to How to prevent a Reload from resubmitting a form?

... but if your server is even slightly slow, impatient users WILL mash the stop-button and resubmit or reload your page.   You have to be prepared for whatever happens, on the server side. nbsp; Anything that happens, can happen at any time, and can happen again, and there is nothing you on the server side can do about it.

However, there are various ways to detect it.   One way, which is often used anyway to avoid CSRF attacks, is to include a hidden field on the form which contains a pseudo-random string.   You save that value in the host-side session store before sending the page.   When a reply comes back, that identical string should still be there, and you should be seeing it for the first time.   If you don’t, then you know that the data is either “stale” or resubmitted or a forgery.   (I have also seen sequence-numbers and server-side Unix timestamps in hidden fields.)   But, you, in your server-side programming, must either do this, or be using a framework that does this for you, because the user-side can do whatever it wants, whenever it wants, rightly or wrongly.   This, BTW, is true of every web programming language, since it is inherent in the design of HTTP.   Even Javascript tricks designed to suppress multiple-mashes can be circumvented if the user successfully reloads the page, and you have to assume that, somehow, that’s what he managed to do.


Comment on Re: How to prevent a Reload from resubmitting a form?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1043128]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (6)
As of 2014-10-25 07:21 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (142 votes), past polls