When I try to login show me token error. I have checked token in view form it\'s right and when comment \\App\\Http\\Middleware\\VerifyCsrfToken::class
,
in the
Add <?php echo Form::token(); ?>
in side the form.
I used the following code. It is working perfectly.
<?php echo csrf_token(); ?>
I had the same problem. I am using Laravel 5.1.28, php 5.6.13
After seeing the TokenMismatchException in VerifyCsrfToken, I searched the web for answers but none solved my problem.
The page did send the token. The token values is also seen in the session file in the directory storage/framework/sessions (I disabled encryption to see it).
Exhausted, I re-install laravel and use simple form for testing - it worked without token mismatch error.
Moving my code to the newly installed laravel piece by piece, I finally found that the problem was caused by doctrine/dbal (I still do not know why).
Removed it from composer.json and the problem disappeared.
In the composer.json, token mismatch error was seen with the following line:
"require": {
....
"doctrine/dbal": "^2.5"
...
},
Your case may be different, but you may want to see if you change anything in composer.json that may be causing the problem.
Edited:
Since you are using Form builder remove this from your form. Laravel form builder automatically adds a hidden token field to your form when you do Form::open()
So remove this line:
<input type="hidden" name="_token" value="{{ csrf_token() }}">
Adding {!! csrf_field() !!}
solved my problem as shown below:
<form action="#" method="post" class="form-horizontal" role="form">
{!! csrf_field() !!}
</form>
If using Laravel Form helper such as below:
{!! Form::open(array('class' => 'form-horizontal', 'role' => 'form')) !!}
CSRF Code will be added automatically in your html script. Also make sure to view the source code in browser to be certain that a field such as below was indeed added.
<input type="hidden" name="_token" value="dHWBudjTyha9AMr0SuV2ABq5NNK6bTIDZDXRWCBA">
I have same problem while using this code
<input type="hidden" name="_token" value="{!! csrf_token() !!}">
<input type="hidden" name="_token" value="{{ csrf_token() }}">
by changing it to {!! csrf_field() !!}
solve my problem
i'm on L5.1