Laravel 5.2 TokenMisMatchException on a production server

I encounter TokenMismatchException on my Production Server, but the application works fine on the local Xampp server and other hosting. This is our home server, so we cannot change it. We must use it, but we do not understand what the problem is.

Please help me, I need to change something on the server, for example, a plug-in, extensions, or something else, Please let me know. Below is a screenshot:

Production error while sending login with empty and geotext market mismatchexception

This is on my personal hosting and the same works fine here.

Above sceenshot is from Production and one of the hosting providers. On a laravel production server, the application gives a tokenmismatchexception, while the same application works fine on a different 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 gave 777 permission to the folder and then did nothing. However, I get this exception.

+6
source share
7 answers

Add this to your html form

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

in the blade

 {!! Form::token() !!} 

And add your route to web middwlware

 Route::group(['middleware' => 'web'], function() { // Place all your web routes here... }); 
+4
source

These are probably sessions that are not set up properly. Try deleting the PHP_SESSID cookie or changing the way sessions are stored on the server.

You can also check if sessions with the test route work correctly.

+2
source

I had the same problem as for creating a token in the configuration file.

Try either the artisan $ php artisan key:generate built-in command, or create the key manually.

+1
source

Perhaps you are having something wrong with the login login. I recently ran into the same problem. In my case, the problem is that I used Auth::login($user,true) instead of Auth::login($user) or Auth::attempt...

Secondly, you should also check if your user base has a remember_token .

Thirdly, you need to check where your session is stored.

Hope this helps!

+1
source

I had this problem, for me the problem was

 SESSION_DOMAIN=custom_domain_here 

Customization in my .env file, which is different from production and local. This will result in incorrect session creation for the domain and a call tokenMismatch.

Hope this helps someone.

+1
source

I had the same problem, I used

 <form role="form" method="POST" action="{{ url('laravel-master/login') }}"> <input type="hidden" name="_token" value="{{ session()->getToken() }}"> 

This line is in my view of the form.

0
source

try checking the session file => Application / Configuration 'domain' => 'ip adresse or Domaine name', and if the domain name has an SSl certificate change the safe variable to True I hope this helps you: D

0
source

All Articles