Laravel 6.x 页面在内核中间件中插入 StartSession 后过期



>我需要通过 Session 向我的控制器的构造函数发送一些值,默认情况下,除非您在内核的中间件块中插入以下 2 行,否则 Session 在构造函数上不可用:

IlluminateSessionMiddlewareStartSession::class,
IlluminateViewMiddlewareShareErrorsFromSession::class, 

问题是,在我放置这些行后,我得到一个419 |我查看的页面已过期消息。

这是我的内核的外观:

protected $middleware = [
AppHttpMiddlewareTrustProxies::class,
AppHttpMiddlewareCheckForMaintenanceMode::class,
IlluminateFoundationHttpMiddlewareValidatePostSize::class,
AppHttpMiddlewareTrimStrings::class,
IlluminateFoundationHttpMiddlewareConvertEmptyStringsToNull::class,
IlluminateSessionMiddlewareStartSession::class,
IlluminateViewMiddlewareShareErrorsFromSession::class,
];   
protected $middlewareGroups = [
'web' => [
AppHttpMiddlewareEncryptCookies::class,
IlluminateCookieMiddlewareAddQueuedCookiesToResponse::class,
IlluminateSessionMiddlewareStartSession::class,
// IlluminateSessionMiddlewareAuthenticateSession::class,
IlluminateViewMiddlewareShareErrorsFromSession::class,
AppHttpMiddlewareVerifyCsrfToken::class,
IlluminateRoutingMiddlewareSubstituteBindings::class,
],
'api' => [
'throttle:60,1',
IlluminateRoutingMiddlewareSubstituteBindings::class,
],
];

我不知道问题是什么,所以我不得不安装一个新的Laravel项目,现在它可以工作了。

相关内容

  • 没有找到相关文章

最新更新