Learn Pain Less

HomeOur TeamContact
Codeigniter 4
How to use Honeypot to prevent from robots in Codeigniter 4 | Security Feature
Pawneshwer Gupta
Pawneshwer Gupta
June 15, 2020
1 min

Table Of Contents

01
Honeypot Class in Codeigniter 4
02
How to enable Honeypot in Codeigniter 4
03
Configuring Honeypot
04
Video tutorial of Honeypot class
How to use Honeypot to prevent from robots in Codeigniter 4 | Security Feature

Honeypot Class in Codeigniter 4

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.

How to enable Honeypot in Codeigniter 4

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.

Configuring Honeypot

Honeypot can be customized. The fields below can be set either in app/Config/Honeypot.php or in .env.

  • hidden - true|false to control visibility of the honeypot field; default is true
  • label - HTML label for the honeypot field, default is ‘Fill This Field
  • name - name of the HTML form field used for the template; default is ‘honeypot
  • template - form field template used for the honeypot; default is ‘{label}

Video tutorial of Honeypot class

You can get full source code of this project from github here

Subscribe to our newsletter!

We'll send you the best of our blog just once a month. We promise.

Tags

PHPhoneypotbot protectionsecurityfeatured

Share


Pawneshwer Gupta

Pawneshwer Gupta

Software Developer

Pawneshwer Gupta works as a software engineer who is enthusiastic in creating efficient and innovative software solutions.

Expertise

Python
Flutter
Laravel
NodeJS

Social Media

Related Posts

How Throttler and Rate limiting work in codeigniter 4
How Throttler and Rate limiting work in codeigniter 4
July 18, 2020
1 min
How to test Socket io with Postman
Postman
How to test Socket io with Postman
July 30, 2021
2 min
Why we have to think about state in flutter (Beginner's question)
Flutter
Why we have to think about state in flutter (Beginner's question)
August 08, 2020
2 min
Learn Pain Less  © 2024, All Rights Reserved.
Crafted with by Prolong Services

Quick Links

Advertise with usAbout UsContact Us

Social Media