Laravel TokenMismatchException

时间:2014-08-12 19:44:00

标签: php laravel csrf

我似乎偶尔会在启用CSRF的表单上遇到此错误。但是一旦你回去尝试再次提交表格,它就可以了。

Illuminate\Session\TokenMismatchException: 
/var/www/laravel/app/filters.php:100 {closure}
[internal]:0 call_user_func_array
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:199 fire
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Events/Dispatcher.php:154 until
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1399 callRouteFilter
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1361 callAttachedBefores
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:1248 callRouteBefore
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:996 dispatchToRoute
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Routing/Router.php:968 dispatch
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:738 dispatch
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:708 handle
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Http/FrameGuard.php:38 handle
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Session/Middleware.php:72 handle
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Queue.php:47 handle
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Cookie/Guard.php:51 handle
/var/www/laravel/vendor/stack/builder/src/Stack/StackedHttpKernel.php:23 handle
/var/www/laravel/vendor/laravel/framework/src/Illuminate/Foundation/Application.php:606 run
/var/www/laravel/public/index.php:49 [main]

如果有任何其他可能有用的信息,请告诉我。谢谢!

1 个答案:

答案 0 :(得分:0)

如果启用了CSRF过滤器并且未使用Form :: token()来生成隐藏的csrf令牌,则会发生此错误。如果您要发送ajax呼叫,通常会错过这个。