Prevent from displaying the default CSRF error page in Codeigniter
Core classes like CI_Security
are instantiated before helpers and libraries - there is no ability to utilize these functions like you would elsewhere in a CI app.
You'll have to duplicate the functionality in the class using native PHP functions like header()
which is not much of a hardship if you'd simply like to redirect to a prettier error page.
One of a way to do is extend Security
class to redirect to the same page.
CodeIgniter User Guide - Extending Core Class
Nice explanation of How to handle an expired CSRF token after a page is left open
For those who want change the page view, you can edit the file error_general.php
in /application/errors/error_general.php
. CodeIgniter uses that file to show general errors, like CSRF Errors.
Regards :).