I enabled the csrf_protection option in codeigniter\'s config file, and used form_open() function to create my forms. But when I submit the form, this error occurs:
My config:
$config['csrf_protection'] = true;
$config['csrf_token_name'] = 'csrf_token_name';
$config['csrf_cookie_name'] = 'csrf_cookie_name';
$config['csrf_expire'] = 7200;
$config['csrf_regenerate'] = false;
$config['csrf_exclude_uris'] = array();
Form:
I did had the same problem. There wasn't any issue with the configuration or any code related bug.
(In my case)
The problem was the form's URL was like http://localhost/project/form
but the form was submitted to http://[::1]/project/form/create
Problem root was the domain name where the CSRF token was generated and the domain where they were checked. Simply changing the form's URL to http://[::1]/project/form resolved the problem with my project.
It was just a minor workaround, this issue never occurred in the actual production domain