This BotDetect Captcha PHP code example shows how to dynamically adjust Captcha configuration, potentially on each Http request made by the client.
Any PHP code setting Captcha properties in the CaptchaConfig.php
file will be executed not only for each protected form GET or POST request (like Captcha configuration code placed in form source would be), but also for each each GET request loading a Captcha image or sound, or making an Ajax Captcha validation call.
If configured values are dynamic (e.g. CaptchaRandomization
helper or other function calls in CaptchaConfig.php
code), they will be re-calculated for each Captcha challenge generated. For example, Captcha ImageStyle
randomized in CaptchaConfig.php
code will change on each Captcha reload button click.
This means your code can reliably keep track of visitor interaction with the Captcha challenge and dynamically adjust its settings. Also, while CaptchaConfig.php
settings apply to all Captcha instances by default, you can also selectively apply them based on CaptchaId.
To show an example of the possible dynamic Captcha configuration adjustments, this code example increases the difficulty of the Captcha test if the visitor associated with the current PHP Session fails a certain number of Captcha validation attempts, and also sets the Captcha locale to Chinese for requests from a certain IP range.
BotDetectâ˘
trademark in the background of 50% of all Captcha images generated.These limitations are removed if you upgrade your BotDetect license.
BotDetect PHP Captcha Library version 4.1.0 Free loaded by PHP version 7.2.34-38+ubuntu18.04.1+deb.sury.org+1