By jaybee1001 on
I know this issue has been addressed many times before, but all of the proposed solutions are client-based and depend on Javascript or JQuery. However, I have a module that is submitting transactions to a 3rd Party service, and I need to trap duplicate submit clicks at the server-side, because I cannot rely on my users having scripting enabled in their browsers.
Can anyone help me understand how to effectively prevent this - perhaps using session data. Ideally I want to stop processing a submission if the user has already submitted in the previous 10 seconds.
Any ideas/help would be GREATLY appreciated.
J
Comments
Check form id via module or Rules?
Saw your post while looking for a plug-in solution for something similar.
I guess the form has a unique or random id that gets posted with the submit. If so then getting the same id twice means either you're very unlucky or the same form is being submitted for a second time.
You could write a module to store submitted form ids, checking whether the form's already been submitted and taking the appropriate action as you go.
Rules can intercept forms at build, validation and submit (I think that's as in 'submit to the database') time, so you should be able to do something similar using that though you'd need to store the submitted form id somewhere. Maybe in $_SESSION?
This is just an idea that I haven't thought through very much. If a module existed to protect things on the server side I'd use it but my case isn't too critical so I'm just going for the javascript Hide submit button option at least for the time being.
A general core issue about
A general core issue about this: #1705618: Double click prevention on form submission
Do you have a AegirCoop support subscription? See https://www.aegirproject.org/#support