laravel获取不到session
session可以存储但是无法获取 修改 app/http/kernel.php文件
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
$this->middleware(function() { $this->admin = session('admin'); $this->isLogin = $this->admin == null ? false : true; });
php开发交流群: 901326020