Forums

can session be used to prevent double submit by single user?

eddddd 19 Feb, 2012
How to prevent a single user from submitting multiple time of a form ? Can session be used to do that ? or there's other solution ?
I'm using CF4 .
GreyHead 19 Feb, 2012
Hi eddddd,

Are these logged in users?

Bob
eddddd 19 Feb, 2012
hi greyhead , I just want to stop users spamming it by clicking the back button on the browser and click submit again and again .

it would be better to have a limit on how many times a user can submit the form in a short time.
GreyHead 19 Feb, 2012
Hi edddd,

OK I understand. CFv3 had an anti-flooding option but that doesn't seem to have made it into CFv4 yet.

Please try this in the serverside validation box.
<?php
// set flood delay in seconds
$flood_interval = 60;

$valid = true;
$session = JFactory::getSession();
$check = $session->get('cf_antiflood', '');
$diff = $check - time();
if ( time() < $check  ) {
  $valid = false;
  $form->validation_errors[] = "Go away please.";
}
$session->set('cf_antiflood', time() + $flood_interval);
return $valid;
?>

Bob
eddddd 19 Feb, 2012
Thanks greyhead ! you are very helpful 😀
andrea68it 23 Mar, 2012
Hi,
I'm using Chronoforms_V4_RC3.21_J1.6
Any suggestion to avoid multiple subit whit this version?

Thanks

Andrea
GreyHead 23 Mar, 2012
Hi Andrea,

Try the Anti Flood action - see two posts before yours.

Bob
andrea68it 07 Apr, 2012
Hi Bob,

Now I'm using AntiFlood.
To test it I set the delay to 5 second.

The first run of the form, display the message given from AntiFlood instead of the thank page.

I've waited 6 second, and at the new submision of the form work fine with the thanks page, and all new submission with a delay < 5 seconds return corectly the AntiFlood message.

Wy AntiFlood is gone in action at the first run of the form?

Thanks
Andrea
GreyHead 08 Apr, 2012
Hi Andrea,

I can only think that perhaps you were still in the time-out period from a previous test. If you test with the default setting of 60 seconds, then change the setting and re-test before the 60 seconds is up then this will happen.

Bob

Later: I've updated the action so that it applies the current value of the time-out period when the form is submitted. Previously it stored the current time + the delay.
This topic is locked and no more replies can be posted.