更新时间:2023-02-19 17:59:22
在5.3
中,中间件尚未在constructor
中运行,因此您无法收集session
数据.但是,使用基于闭包的方法,您应该可以通过以下方式访问它:
In 5.3
the middleware hasn't run yet in the constructor
, so you're unable to gather session
data. But using your closure-based approach, you should be able to access it with something like this:
$this->middleware(function($request, $next) {
// Get the session value (uses global helper)
$this->token = session('_admin_id');
// If the value is null, abort the request
if (null === $this->token) abort(404);
return $next($request);
});