dongzhiman2162 2018-09-06 05:33
浏览 55

VerifyCsrfToken.php第68行中的TokenMismatchException:Laravel 5.3

I have been looking for answers around the net for 3 hours now, and have tried so many solutions but it did not work. I have tried: answers from here

But none of them worked

Solution 1:

sudo rm -rf storage/framework/sessions/*
sudo php artisan cache:clear

Solution 2:

Clearing my cache and cookies in my browser, then running

php artisan config:cache and php artisan cache:clear

Solution no. 3

enter image description here

Solution no. 4

enter image description here

Solution no.5

I tried changing my {{ csrf_field() }} to {!! csrf_field() !!}

Solution no. 6

I tried moving Auth::routes(); on top of my web routes.

Solution no. 7

enter image description here

Solution no. 8

I have changed my code from:

 <form class="form-horizontal" role="form" method="POST" action="{{ url('/login') }}">
   {{ csrf_field() }}

to:

 <div class="panel-body">
    {!! Form::open([ 'route' => 'login', 
                     'method' => 'POST' ]) !!}

I even tried adding a {{ csrf_field() }} in Form::open

I even tried adding another bracket {{{ csrf_field() }}}

Solution no. 9

Desperately restarting my server(MAMP) then clearing cache

There is another solution, which says that I should download a fresh install of Laravel, but I cannot do that because this is a big project.


Here is my .env file

API_DEBUG=true
APP_ENV=local
APP_KEY=base64:g43UiAlu11L/y9ThUjiVqFi52/d2Jf/JHaPNwkwzU4o=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://127.0.0.1

BROADCAST_DRIVER=log
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

SESSION_SECURE_COOKIE=true

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

PUSHER_APP_ID=
PUSHER_KEY=
PUSHER_SECRET=

API_PREFIX=api
API_SUBTYPE=app
API_VERSION=v1

JWT_TTL=20160

SIGN_UP_RELEASE_TOKEN=false
PASSWORD_RESET_RELEASE_TOKEN=false

PAGINATION_ITEMS_PER_PAGE=10

# Database Connections

DB_CONNECTION=mysql-core
DB_CORE_HOST=localhost:8889
DB_CORE_PORT=3306
DB_CORE_DATABASE=core
DB_CORE_USERNAME=root
DB_CORE_PASSWORD=root

my Kernel.php

class Kernel extends HttpKernel
{
protected $middleware = [
    \Illuminate\Foundation\Http\Middleware\CheckForMaintenanceMode::class,
];

/**
 * The application's route middleware groups.
 *
 * @var array
 */
protected $middlewareGroups = [
    'web' => [
        \App\Http\Middleware\EncryptCookies::class,
        \Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
        \Illuminate\Session\Middleware\StartSession::class,
        \Illuminate\View\Middleware\ShareErrorsFromSession::class,
        \App\Http\Middleware\VerifyCsrfToken::class,
        \Illuminate\Routing\Middleware\SubstituteBindings::class,
        'secure.requests',
    ],

in my session.php

'driver' => env('SESSION_DRIVER', 'file'),
'files' => storage_path('framework/sessions'),
'domain' => env('SESSION_DOMAIN', null),
'secure' => env('SESSION_SECURE_COOKIE', false),

Here's my web.php

<?php

Route::group([ 'middleware'  => [ 'secure.requests' ] ], function() {

    Auth::routes();

    Route::get('/', function () {
        return view('welcome');
    });

});

I am also using the laravel dubugbar enter image description here

It's a long post, but I am desperate to be able to solve this. I hope someone can help me.

EDIT: I tried logging in from the API side (locally) and it works. the problem is just the web side.

  • 写回答

3条回答 默认 最新

  • dongliulu1122 2018-09-06 06:00
    关注

    I have faced the same issue once, try to run the command below from the project directory:

    chmod 777 storage/framework/sessions/

    I hope it will work for you!

    评论

报告相同问题?

悬赏问题

  • ¥15 安卓adb backup备份应用数据失败
  • ¥15 eclipse运行项目时遇到的问题
  • ¥15 关于#c##的问题:最近需要用CAT工具Trados进行一些开发
  • ¥15 南大pa1 小游戏没有界面,并且报了如下错误,尝试过换显卡驱动,但是好像不行
  • ¥15 没有证书,nginx怎么反向代理到只能接受https的公网网站
  • ¥50 成都蓉城足球俱乐部小程序抢票
  • ¥15 yolov7训练自己的数据集
  • ¥15 esp8266与51单片机连接问题(标签-单片机|关键词-串口)(相关搜索:51单片机|单片机|测试代码)
  • ¥15 电力市场出清matlab yalmip kkt 双层优化问题
  • ¥30 ros小车路径规划实现不了,如何解决?(操作系统-ubuntu)