php - 仅在实时服务器上 VerifyCsrfToken.php 第 67 行中的 TokenMismatchException

标签 php laravel-5 laravel-5.2

当我尝试在 Laravel 5.2 中使用 auth 时出现此错误。那是在移动到实时服务器之后发生的。在我的本地服务器上一切正常。

Token inside form 和 is Session:token() 是一样的。

更新:我把 dd($request) 放在 laravel/framework/src/Illuminate/Foundation/Http/Middleware/VerifyCsrfToken.php

并且 _token 值不匹配表单中的 _token 输入。

我试过:

  • 为 auth 路由禁用 CSRF,在 except 数组中添加路由 Midd/VerifyCsrfToken.php。
    • 为/storage/bootstrap 文件夹设置 777 权限。
    • 用过{!! csrf_field() !!} 和 name="_token"value="{{ csrf_token() }}">.
    • 更改了 config/session.php 中的域。
    • php artisan key:generate.
    • 重新安装 Auth。 还有我有 middleware = auth.basic 的路由,即使一开始没有要求登录,我也会收到“无效凭据”。

在我的本地服务器上它工作正常。

最佳答案

你的handler是这样的吗?

<?php 
...
public function handle( $request, Closure $next )
{
    if (
        $this->isReading($request) ||
        //$this->runningUnitTests() ||
        $this->shouldPassThrough($request) ||
        $this->tokensMatch($request)
    ) {
        return $this->addCookieToResponse($request, $next($request));
    }

    // redirect the user back to the last page and show error
    return Redirect::back()->withErrors('Sorry, we could not verify your request. Please try again. (You waited too long to submit your form)');
}

关于php - 仅在实时服务器上 VerifyCsrfToken.php 第 67 行中的 TokenMismatchException,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40282316/

相关文章:

php - 用 PHP 显示日文字符

javascript - 看似有效的 JSON 上的 JSON.parse 错误

php - 在 Laravel 中找不到错误列

php - 在 laravel 中处理模型中的关系

php - 通过回显将日期时间/时间戳从 PHP 传递到 Javascript

php - 我如何将背景颜色与 PHP 匹配以匹配文本颜色?

php - Laravel 使用原始字符串创建表

mysql - laravel,groupby()中的子字符串

php - Laravel 5.2 数据库模式自行创建一个唯一列

php - laravel中的双冒号是什么意思