Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>Often people overlook the most conventional way to handle this which is to use <strong>nonce keys</strong>.</p> <p>You can use <strong><a href="http://en.wikipedia.org/wiki/Post/Redirect/Get" rel="noreferrer">PRG</a></strong> as others have mentioned but the downside with PRG is that it doesn't solve the double-click problem, it requires an extra trip to the server for the redirect, and since the last step is a GET request you don't have direct access to the data that was just posted (though it could be passed as a query param or maintained on the server side).</p> <p>I like the Javascript solution because it works <em>most</em> of the time.</p> <p><strong>Nonce keys</strong> however, work all the time. The nonce key is a random unique GUID generated by the server (also saved in the database) and embedded in the form. When the user POSTs the form, the nonce key also gets posted. As soon as a POST comes in to the server, the server verifies the nonce key exists in its database. If it does, the server deletes the key from the database and processes the form. Consequently if the user POSTs twice, the second POST won't be processed because the nonce key was deleted after processing the first POST.</p> <p>The nonce key has an added advantage in that it brings additional security by preventing <a href="http://en.wikipedia.org/wiki/Replay_attack" rel="noreferrer">replay attacks</a> (a man in the middle sniffs your HTTP request and then replays it to the server which treats it as a legitimate).</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload