Laravel 5.0 TokenMismatchException and DecryptException exceptions/errors
Dear All,
We are having problems with our Laravel 5.0 application that we just can't seem to get to the bottom of and would really appreciate if anyone could shed any light on this. I have seen a few threads with people mentioning the same symptoms, yet nothing concrete which suggests the cause and more importantly the fix.
We are using a lot of Ajax with Angular and roughly 1 in every 10 - 50 requests there is a token mismatch or DecryptException exception.
'Illuminate\Session\TokenMismatchException' in laravel\framework\src\Illuminate\Foundation\Http\Middleware\VerifyCsrfToken.php:46
and
Illuminate\Contracts\Encryption\DecryptException' with message 'MAC is invalid.' in laravel\framework\src\Illuminate\Encryption\Encrypter.php:147
I have been logging out the tokens each time and when there is a token mismatch it is the $request->session()->token() which is different not the token sent from Angular.
The next request after the exception will be back to how it was before and the request will complete as expected.
All the posts I have seen about token mis matches, talk about measures to take to ensure the token sent from the client is correct, but I have not seen anything that focuses on Laravel reading the incorrect token.
Any help is much appreciated.
Thanks Craig
Please or to participate in this conversation.