Last updated on October 9th, 2019 at 11:45 am

In this tip I can explain how we can disable CSRF token in CakePHP 3. You can add this code in beforeFilter() method. This code helps you to fix CSRF Token Mismatch.

public function beforeFilter(Event $event)
{
    if (in_array($this->request->getParam('action'), ['method1', 'method2'])){
        $this->getEventManager()->off($this->Csrf);
    }
}

Hope this tip helps you.