What are CSRF Functions in CodeIgniter 4 Tutorial
There are several functions available in CodeIgniter 4 which helps us to implement the concept of CSRF in web forms. Inside this article we will see the list of all available CSRF functions in codeigniter 4.
By the help of these functions, we implement the concept of CSRF token at header or we add at form level. So this tutorial will be very interesting to see and learn.
We have few articles on the same topic, you can learn it as well.
- Implementation of CodeIgniter 4 CSRF Token
- CodeIgniter 4 CSRF Token with Ajax Request
- How to Fix Session Fixation Session Hijacking Attack in CodeIgniter ?
Note*: For this article, CodeIgniter v4.1 setup has been installed. May be when you are seeing, version will be updated. CodeIgniter 4.x still is in development mode.
Here is the command to install via composer –
$ composer create-project codeigniter4/appstarter codeigniter-4
Assuming you have successfully installed application into your local system.
What is Cross-site request forgery (CSRF) ?
Cross-Site Request Forgery (CSRF) is an attack which forces an end user (an unauthenticated user of site) to execute/run unwanted actions on a web application. These requests sometimes crash the database. This saves attacking data into database tables and execute accordingly and may down the application.
This is a normal attack which every development or even web owner needs to do it first.
In CodeIgniter 4, we have few functions available which helps to integrate a CSRF token value easily inside web forms.
Available CSRF Functions in CodeIgniter 4
There are some functions in CodeIgniter 4 which provides the functionality to work with CSRF token and web forms.
- csrf_token()
- csrf_header()
- csrf_hash()
- csrf_field()
- csrf_meta()