can you show your code?
Working fine on localhost but on live (1/1) TokenMismatchException in VerifyCsrfToken.php (line 68)
Hello Laracasts Experts,
Got stuck with this (1/1) TokenMismatchException in VerifyCsrfToken.php (line 68). PRoject is working fine on localhost server but on my live server it's getting Tokenmistach exception. I have done alot of research, but everything seems like i did earlier in the project.
For example :- -- Inside form {{ csrf_field() }}
-- Permissions is also correct. also i have checked with cleared cookies.
Please do help me I ll be thankful to you expert guys. I am getting stuck with this. little frustration in my mind now.
If you can chemck the live url is http://pullist.testingwebsitedesign.com/
Here is the login form:- Perfectly fine everything on local but on live.
I ve putted {{ csrf_token() }} just after form
<form class="form-horizontal" method="POST" action="{{ route('login') }}" >
{{ csrf_token() }}
<div class="form-group{{ $errors->has('email') ? ' has-error' : '' }}">
<!-- <label for="email" class="col-md-4 control-label">E-Mail Address</label> -->
<input id="email" type="email" class="form-control" placeholder="Email" name="email" value="{{ old('email') }}" required autofocus>
@if ($errors->has('email'))
<span class="help-block">
<strong>{{ $errors->first('email') }}</strong>
</span>
@endif
</div>
<div class="form-group{{ $errors->has('password') ? ' has-error' : '' }}">
<!-- <label for="password" class="col-md-4 control-label">Password</label> -->
<input id="password" placeholder="Password" type="password" class="form-control" name="password" required>
@if ($errors->has('password'))
<span class="help-block">
<strong>{{ $errors->first('password') }}</strong>
</span>
@endif
</div>
<button type = "submit" class = "btn btn-default">Submit</button>
<p>Dont't have a ccount?</p>
<a href="{{ route('register') }}" class = "btn btn-default" >Sign Up</a>
</div>
<p class="forget"><a class="btn btn-link" href="{{ route('password.request') }}">
Forgot Your Password?
</a></p>
</div>
</form>
If you find something please post it here, I have had the same issue with logins and forms on my side. Locally the login/logout works and my forms all submit, but on the live server my login/logout does not work correctly. And my forms all throw the token mismatch error on submit.
It seems that working fine your code.
Go to routes/web.php and check whether is there any gap (space) before starting <?php or not. If there is a gap, just remove and try again.
Few developers face this issue because of this.
One more technique you can try. Run php artisan cache:clear.
Or alternatively run in incognito window in your browser to check whether its working or not.
can you try with {{ csrf_field() }} instead of {{ csrf_token() }} ?
@mushood yes i tried with both of.
Few other possibilities-
1
Use this
{!! csrf_field() !!}
Instead of
{{ csrf_field() }}
2
Go to
config->session.php
'domain' => env('SESSION_DOMAIN', null),
Remove SESSION_DOMAIN from the file (.env)
and fun-
composer dumpautoload
If there any problem with my live domain server to create tokens / Matching tokens?
have you tried all of my way?
@tisuchi Thanks but not work for me. I found that during my research but not work.
@krishna9720 Can you please paste your routes/web.php over here?
I have checked now another thing is it's very strange that my session token and request token is different
array:2 [▼
"SessionToken" => "FA8fSJBGzhPUOiouuVrwIP9Q8bFxmZ0HtBPNEPJf"
"RequetedToken" => "sY9k2g9ZFvjcr4e07r0PTv6IQk7uWMDOBUdU6x5L"
]
What can be possible reason for that ?
Here it is
Route::get('/', function () {
return view('/auth/login');
});
Route::group(['middleware' => ['guest']], function () {
Route::get('admin/login', 'backend\Auth\LoginController@getLoginForm');
Route::post('admin/authenticate', 'backend\Auth\LoginController@authenticate');
Route::get('admin/register', 'backend\Auth\RegisterController@getRegisterForm');
Route::post('admin/saveregister', 'backend\Auth\RegisterController@saveRegisterForm');
// USER
Route::get('user/login', 'Auth\LoginController@getLoginForm');
Route::post('user/authenticate', 'Auth\LoginController@authenticate');
Route::get('user/register', 'Auth\RegisterController@getRegisterForm');
Route::post('user/saveregister', 'Auth\RegisterController@saveRegisterForm');
Route::get('inventoryadmin/login', 'backend\Auth\LoginController@getInventoryAdminForm');
Route::post('inventoryadmin/authenticate', 'backend\Auth\LoginController@inventoryauthenticate');
});
@tisuchi can you please tell me why my session token and request token is different. that's why the auth is unable to verify. please do help me.
Thanks K.
Are you using any js framework like angular / vue / react?
@tisuchi Not right now, I am just using Laravel framework.
@krishna9720 Please have a look over here click here
Not sure if this is related to other folk who are seeing this - but we had an app that behaving this way and it seemed to be that at one point it had been run with config:cache - then someone had manually edited the .env file and run config:clear but not then done a cache call again. Just running a final config:cache seemed to make the vast majority of the problem go away.
Anyway - might help someone :-)
I have same issue
@paragbhavsar Dude create a new post, this one is five years old. Its probably using Laravel 5!
Please or to participate in this conversation.