To enable CRSF in Codeigniter, you just need to:
Set the parameter "TRUE" in the configuration file
All your forms MUST use the form_open () helper function . This will automatically generate and add a βhiddenβ CSRF token to your forms. Codeigniter then automatically checks this token on each form submission as part of the security function. If it detects a CSRF error, it will automatically generate error 401.
You do not have to do anything.
edit: I just re-read that you are not using form_open (). Perhaps you can manually insert the CSRF token into the forms yourself, but it will be more work than required. Just convert all your forms to use form_open - and it will work without visible results.
(And yes - this is one of the few poorly documented functions in CI - so I understand why you could not find the answer - it took me some time too)
source share