Loading…

What is CSRF and how you can enable CSRF in CodeIgniter?

In codeIgniter CSRF token is a random generated value that changes with each HTTP request sent by webform. When the form is submitted by user then website checks this submitted CSRF token equals or not the saved in the session.

We can enable CSRF protection from config.php and update the following values

$config['csrf_protection'] = TRUE;
$config['csrf_token_name'] = 'csrf_test_name'; //The token name
$config['csrf_cookie_name'] = 'csrf_cookie_name'; //The cookie name
$config['csrf_expire'] = 7200; // It will expire after this given time.

Suggest An Answer

No suggestions avaliable!

Latest post from CodeIgniter Interview Questions

Ask Question