I am encountering TokenMismatchException on my Production Server, but the application working fine on local Xampp server and another hosting. It our in house server, so we cannot changed it. We have to use it, but we did not understand where is the issue.
Please friends help me, did i need to change anything in server like plugin, extensions or anything else, Please let me know. Here is screen shot below:
Above sceenshot is from Production and one of hosting provider. On production server laravel application giving tokenmismatchexception whereas same application working fine on another hosting provider. We did not understand why this is happening. Please suggest us what to do.
Update:
I have fresh laravel 5.2 and run php artisan make:auth
after that i have given 777 permission to the folder, then donw nothing. Still i am getting this exception.
Add this in your html form
<input type="hidden" name="_token" id="_token" value="{{csrf_token()}}">
in blade
{!! Form::token() !!}
And add your route in web middwlware
Route::group(['middleware' => 'web'], function() {
// Place all your web routes here...
});
This is probably the sessions that are not being set properly. Try to delete your PHP_SESSID cookie or change the way the sessions are stored on the server.
You can also check if sessions are working properly with a testing route.
I had this issue, for me the problem was
SESSION_DOMAIN=custom_domain_here
Setting in my .env file, which was different between production and local. This will cause the sessions to be created incorrectly for the domain and throw a TokenMismatch.
Hope this helps someone.
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