3

I'm trying to migrate laravel from version 5.2 to 6.0 , but i have different folder for different version in same local wamp server . I'm using same database file both version . But i'm always getting csrf token mismatch and page expired . Please give me some good solutions for this.

Adil Basha
  • 31
  • 1
  • 2

1 Answers1

1

This problem comes from the CSRF token verification which fails. So either you're not posting one or you're posting an incorrect one.

Use {{ csrf_field() }} in your form

OR

Add Your Route URL into the Http/Middleware/VerifyCsrfToken.php file.

Example Like this. If your ajax route Route::post('searchsubmit','User\UserController@ViewSearchList')->name('searchsubmit');

Http/Middleware/VerifyCsrfToken.php

protected $except = [
       'searchsubmit',
    ];

In Your Case You need to add login like this

protected $except = [
           'login',
        ];
Vaibhavi S.
  • 1,083
  • 7
  • 20
  • `cache:clear` is for flushing your cache store, it has nothing to do with the configuration or anything like that – lagbox Dec 02 '19 at 12:15
  • 1
    `php artisan config:cache` also runs `php artisan config:clear`. And caching config on DEV systems is not advised – brombeer Dec 02 '19 at 12:15
  • this is a good solution but i dont recommend that. you should put csrf token for all your forms. maybe php clear all config and caches help you. you can also check @csrf instead of csrf_token() – ali Falahati Dec 02 '19 at 12:19
  • 1
    @kerbholz finally someone else who gets that point about not needing it cached on development :) drives me crazy everytime someone says to cache it – lagbox Dec 02 '19 at 12:20
  • i used all above command , my problems is when another guys use same laravel project from my system in his system from networks this problems occur. – Adil Basha Dec 02 '19 at 12:21
  • @aliFalahati I'm using csrf_token in all forms , for repeatation of code i'm using csrf_token in master blade page . – Adil Basha Dec 02 '19 at 12:43