Honeypot Class makes it possible to determine when Bot make request using form in Codeigniter 4 project. This can be enabled inside
Application\\Config\\Filters.php file of CI4 project. By attaching a hidden field in every form inside your CI4 project automatically. This hidden field is not visible to users but accessible to Bots. So when ever this field’s value is not empty then CI4 throw ”HoneypotException” and crash the webpage to abort request made by Bot and prevents your CI4 project from spam.
To enable Honeypot class in your CI4 project you have to modify ”app/Config/Filters.php” file. Just uncomment ’honeypot’ options from ”$globals” array. Do the following change in this file. (If you don’t understand how to do this then you can watch our Youtube video, Video link is in the end of this post).
After making the above change your CI4 project is ready to protect from spam. You don’t have to do anything with this. But you can customize settings according to your need which is totally optional.
Honeypot can be customized. The fields below can be set either in app/Config/Honeypot.php or in .env.
You can get full source code of this project from github here