Skip to main content
Inspiring
February 3, 2012
Answered

How to stop double clicks registering in a SQL update

  • February 3, 2012
  • 1 reply
  • 3231 views

I have a banner server where an end user clicks on a banner, the link goes to my redirect script CLK.CFM, this page records the click through into the SQL dbase and then it has a CFLOCATION to redirect the user to the appropriate web site.

The problem I am seeing is that when there is a delay from the 3rd party site that the end user is clicking multiple times and it's actually recording multiple clicks in the database

I tried writing some simple code where the page that displays the banner sets a session variable, session.click="1", then when they hit the CLK page I check for the value of session.click, if it's empty I don't SQL update, just go straight to the CFLOCATION,  but if there is a value of 1 I update the database and then I set session.click as empty, so in theory only one click should ever record, but even with the longest delay the CFLOCATION will still do it's thing.

Yet after all that, I still see the multiple clicks, and the timestamp shows they happen within a second or or less of each other, so it's definately a multiple press.

Anybody have any idea why my approach above might not work and what I should do to stop this?

Thanks

Mark

This topic has been closed for replies.
Correct answer BKBK

Got it.

I actually placed it on the CFM page that pulled in the template so the whole page was covered, not sure if that causes any potential issues, but so far it actually seems to have done the trick!!! I'm just keeping a close eye on it

So basically anything that changes the session.click in anyway, I should have the lock around. I had also cflock'd a good chunk of the CLK click through page, all of it aside from the last command for the CFLOCATION.

I'll give it 24 hours and see if it pans out, and if so maybe I'll try less CFLOCK'd code to see if that still works


ACS LLC wrote:

Got it.

I actually placed it on the CFM page that pulled in the template so the whole page was covered, not sure if that causes any potential issues, but so far it actually seems to have done the trick!!! I'm just keeping a close eye on it

So basically anything that changes the session.click in anyway, I should have the lock around. I had also cflock'd a good chunk of the CLK click through page, all of it aside from the last command for the CFLOCATION.

I'll give it 24 hours and see if it pans out, and if so maybe I'll try less CFLOCK'd code to see if that still works

Nice to hear it's holding up so far. I would experiment with some quickfire double and triple clicking. Good luck.

1 reply

Inspiring
February 3, 2012

The best way to prevent double submissions is to take the user off the page with the link or form as quickly as possible.  On your click.cfm, you might consider something like this:

output an empty string or a short blurb of text or whatever.

cfflush

use cfthread for your insert code

cflocation to the website.

ACS LLCAuthor
Inspiring
February 3, 2012

Hey Dan,

When you say as quickly as possible, as you saying that double clicks could still occur? Any idea why my session with cleared session still allows the double records, it looks like even changes to the value of the session variable does not occur fast enough

I've never utilized CFTHREAD will have to read up on that, and I've used CFFLUSH once before, but not sure how that would benefit or how I would use that to counteract this issue?

Thanks

Mark

Inspiring
February 3, 2012

A user can click what's available as long as it's available.  Therefore the objective is to make the link/button/whatever unavailable as quickly as possible once it's selected the first time.

The fastest way to achieve this is with js.  We have a custom tag that uses js to do this and it works wonderfully almost all the time.  For us, that's usually good enough but not always.

cffflush could help you because it brings your user to click.cfm before everything has processed.  Once they are there, whatever they selected to get there is no longer available to select again.

Regarding what you are attempting, I'm missing something.  On what page does the banner display?