cakephp 3.6 CSRF token mismatch in post request

2.4k Views Asked by At

When I submit I Will get following error.

enter image description here

I have loaded CSRF Component.

Let me know why this error coming.

Thanks

1

There are 1 best solutions below

0
On

According to the stacktrace you are using both, the CSRF middleware (see src/Application.php) and the CSRF component (see src/Controller/AppController.php) - you should use only one of them! The component is deprecated, so ideally use the middleware.

If you have both enabled, then the CSRF middleware will be invoked first, and after validating the submitted token, it will unset it from the request data, so that the subsequent token check in the CSRF component will fail with the error that you are seeing.

See also