Post requests work fine running Laravel 5 app on PHP 5.4. Post requests on the same app running on PHP 5.6.9 generate:
TokenMismatchException VerifyCsrfToken.php on line 46
This happens on every post request on both WAMP and IIS. Happens using database sessions and file sessions. Did a full reinstall and also tried all suggestions made here: https://laracasts.com/discuss/channels/general-discussion/keep-getting-tokenmismatchexception-verifycsrftokenphp-on-line-46?page=2. Folks are disabling the Csrf middleware as a fix, but that is not a viable solution. Any help appreciated.
When I realized this was only happening in IE and Chrome, but not Firefox, it led me to the fix. The app was using AddThis share buttons and the javascript was adding an iframe to the pages. This issue is resolved by adding a P3P header to the VerifyCsrfToken Middleware. Hope this saves somebody the hours I lost.
public function handle($request, Closure $next)
{
$response = $next($request);
if (last(explode('\\',get_class($response))) != 'RedirectResponse') {
$response->header('P3P', 'CP="IDC DSP COR ADM DEVi TAIi PSA PSD IVAi IVDi CONi HIS OUR IND CNT"');
}
return $response;
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With