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.
I have faced the same issue and I could solve it by just adding the following package on top: "Spatie\Permission\PermissionServiceProvider::class,"
just add
{{ csrf_field() }}
to your form block and it will save you lot of timeput
<meta name="csrf_token" content="{{ csrf_token() }}">
so token is always available and use that with your AJAX request: ex: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.
For anyone, who is facing this issue in spite of adding
{{ csrf_field() }}
in theform
field and even by adding this in the head tag<meta name="csrf-token" content="{{ csrf_token() }}">
The issue is with writing in the storage because of not adding your current user on Linux in the right group. Make sure to add your current user to
www-data
group. Write this commandMake sure to give right permission to storage folder as well in the laravel app.
I hope this helps.