CSRF validation giving error after a time without use

Asked

Viewed 532 times

2

I have an application already running with codeigniter and I have csrf enabled in the system. The problem is on a page that has a form that sends to itself, is a filter, but it is the following, the user does the post and has the results on the screen, so far it is all right, but if the user leaves the page open, then goes and shuts down the computer and another day it turns on the PC and opens on the same page me an error that the user does not have permission The action you have requested is not allowed.. What I want to know is if there is a way to catch this error in _Construct or how can I know this error in order to redirect the user to some other page?

1 answer

4


The answer to your question is here: https://ellislab.com/forums/viewthread/207249/#964738

Basically, you should extend the Ci_security class. To do this, create a file called My_security.php in application/core/ and change the functionality of the csrf_show_error() method to suit your needs:

class MY_Security extends CI_Security {

    public function __construct()
    {
        parent::__construct();
    }

    public function csrf_show_error()
    {
        // adicione seu redirecionamento aqui
    }

}

I hope I’ve helped.

  • Certainly helped, simple and straightforward.. Even valew

Browser other questions tagged

You are not signed in. Login or sign up in order to post.