Laravel Session() 失效的问题
作者:互联网
之前因为自己自定义了后台的路由,然后路由定义的乱七八糟的。 突然发现session失效了,记录一下,避免后者遇坑。
路由组统一通过web中间件或者存在于一个中间件中
protected $middlewareGroups = [
'web' => [
\App\Http\Middleware\EncryptCookies::class,
\Illuminate\Cookie\Middleware\AddQueuedCookiesToResponse::class,
\Illuminate\Session\Middleware\StartSession::class,
// \Illuminate\Session\Middleware\AuthenticateSession::class,
\Illuminate\View\Middleware\ShareErrorsFromSession::class,
\App\Http\Middleware\VerifyCsrfToken::class,
\Illuminate\Routing\Middleware\SubstituteBindings::class,
],
'api' => [
'throttle:60,1',
'bindings',
],
];
如上,不同组之间的session不一致
Route::group(['middleware'=>'web'],function (){
.....
所以,如果数由文件拆分之后,共享 Session 的数由组之间,应当拥有共同的 Middleware 如 web
标签:Laravel,web,Illuminate,Middleware,Session,失效,class,路由 来源: https://www.cnblogs.com/mouseleo/p/10510077.html