Laravel 5.5 登录和注册页面说:由于不活动,页面已过期.[TokenMismatchException]

2021-12-18 00:00:00 php laravel laravel-5.5

我刚刚使用laravel安装程序创建了一个laravel 5.5版本的新项目.并运行命令php artisan make:auth".为用户身份验证生成视图和控制器.还有运行php artisan migrate"创建数据库中需要的表.访问登录页面和注册页面时,填写表单并提交.显示页面因不活动而过期.请刷新并再试一次.".但刷新页面没有任何帮助.在源码中看到,是哪里导致了异常:

I just created a new project of laravel version 5.5 with the laravel installer.And run the command "php artisan make:auth".The views and controller are generated for the user authentication.And also run "php artisan migrate" to create tables needed in the database.When visiting the login page and register page,filling the form and submit.It shows "The page has expired due to inactivity. Please refresh and try again.".But refreshing the page does nothing help. Seen in the source code,where causes the exception:

if ($e instanceof ModelNotFoundException) {
        $e = new NotFoundHttpException($e->getMessage(), $e);
    } elseif ($e instanceof AuthorizationException) {
        $e = new AccessDeniedHttpException($e->getMessage());
    } elseif ($e instanceof TokenMismatchException) {
        $e = new HttpException(419, $e->getMessage());
    }

似乎是TokenMismatchException"导致了这个问题.这是什么时候发生的?为什么?我只是创建了这个新项目,没有做任何其他更改.希望你得到积分.我使用 php 7.1.9(laravel 5.5 需要 php > 7.0.0).并在开发环境中使用:php artisan serve

It seems "TokenMismatchException" causing this problem. When did this happen?And why?I just create this new project and did not do any other changes. Hope you got the points. I use php 7.1.9(laravel 5.5 requires php > 7.0.0).And serve the project in develop environment with:php artisan serve

推荐答案

我在 localhost:8000 (php artisan serve) 上遇到了同样的问题.也许这是巧合,但请尝试使用 "clean browser" ,而不是您在以前的开发中使用的.对我来说它奏效了.

I had the same problem on localhost:8000 (php artisan serve). Maybe it's coincidence, but try on "clean browser" , other than you used with previous development. For me it worked.

问题似乎出在同一 url 上使用以前的 Laravel 版本开发的 cookie.

It seems that the problem is with cookies from development with previous Laravel versions, on the same url.

相关文章