简体   繁体   中英

How to validate a button click on client side

Let's say, i have a website and it has one button: click me , and also a counter which counts how many times people clicked on the button. The thing is, how to validate if the clicker is a real person, that he clicked only once etc ? Ip's can be changed. Also, it's not a good choise to make a whole account system for a single button.

You can use Google Invisible ReCAPTCHA . It's not 100% reliable when it comes to detect bots (it has been proven mutliple times by the past) but still very efficient.

However, to detect if a single person have clicked only once, there is no viable solution I think. You can maybe add a cookie and check if the cookie exists but it can be easily bypassed by simply deleting the said cookie.

1.- You can save the count in the cache to make it accessible on the backend side. 2.- In the Frontend you cannot access to the IP, so you won't be able to check at that level. 3.- Maybe what you're looking for is a button with a Post in a login website, then everytime the button is clicked you can send the post with the user information and saved. 4.- To validate if'¡ it is a human you can use Google Captcha .

Hope this helps you!

To authenticate a unique device, you can store MAC, IP address, and User Agent. Of course, all those can both be spoofed to allow multiple clicks. That solution would also limit to one person per device, which may not be your intent. Storing User Agent with the MAC address is more difficult to get around than a cookie (that can be deleted).

You can eliminate the most common bots by their user agent, or you can use a CAPTCHA.

You authenticate persons by email account or OpenID, but I assume you want to make clicking the button as easy as possible.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM