Custom error message for Csrf validation |
Hi,
how can we have custom error message displayed when the CSRF validation fails instead of the exception thrown usually? Thanks. (11-18-2023, 06:58 PM)kenjis Wrote: See https://codeigniter4.github.io/CodeIgnit...on-failure I don't want to redirect back. I just want to display a simple message when the csrf request has failed.
Try/catch the SecurityException and show an error message you want.
Check the CI4 source code. The classname is \CodeIgniter\Security\Exceptions\SecurityException.
If you try to catch the exception in your controller, sorry you can't.
Because CSRF filter throws the exception. The controller is not executed yet. Customize CSRF filter. |
Welcome Guest, Not a member yet? Register Sign In |