Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.7k views
in Technique[技术] by (71.8m points)

laravel 5.2 - TokenMismatchException in VerifyCsrfToken.php Line 67

I know that this is a known error with things like forms in Laravel. But I am facing an issue with basic authentication in Laravel 5.2.

I created the auth using Laravel;

php artisan make:auth

Now I have the same copy of code on my server and my local. On my local I am getting no issue whatsoever. However on my server, when I try to register a user I get the error saying TokenMismatchException in VerifyCsrfToken.php Line 67

Both my local and server environments are in sync, yet I keep getting the error on registration. Any help on how I can fix this?

Screenshot of Error

Question&Answers:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

I'm assuming you added $this->middleware('auth'); inside the constructor of your controller to get the authentication working. In your login/register forms, if you are using {!! Form::someElement !!}, add the following line at the top as well:

{!! csrf_field() !!}

Or if you are using input tags inside your forms, just add the following line after <form> tag:

<input type="hidden" name="_token" value="{{ csrf_token() }}">

Hope this helps.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...