'_Token' was not found in request data

I’m getting this error and I’ve no idea why!

‘_Token’ was not found in request data.

Well after following the code i know that it’s because the request data doesnt have a _Token value

There’s a function that checks this called _validToken()

I’ve no idea why this particular form is doing this though as other forms are working perfectly

Could use a few pointers here

Can anyone out there give me some idea what to look for?

Would be much appreciated

Hi

So i figured this out eventually

It was such a simple problem

I had something like this at the end of my form:

<?= $this->Form->button(__('Submit')); $this->Form->end() ; ?>

It works. It also works when you turn on auth. But it stops working as soon as you load the security component

Change it to this:

<?= $this->Form->button(__('Submit')) ?> <?= $this->Form->end() ?>

And it works with the security component

Silly mistake i suppose but hard to find because it worked fine for most if the development process and then broke when i added the security component!

1 Like

hmm, would like to know the exact explanation of that issue.

I mean syntactically it is obviously incorrect because in the first version you practically say:

echo statement; statement;

maybe the second statement is just ignored then and the form just works fine as a lot of broken HTML does?

but how is it connected to the security component?

Please refer: https://stackoverflow.com/questions/37360734/token-was-not-found-in-request-data-in-cakephp3-after-server-migration/52054949#52054949