我有以下两个申请:
我想访问从CorePHP应用程序到Laravel应用程序的会话。
为此,我使用了以下过程:
<?php
namespace App\Http\Middleware;
use Illuminate\Foundation\Http\Middleware\VerifyCsrfToken as Middleware;
use Closure;
use Illuminate\Support\Facades\Session;
use Illuminate\Http\Response;
use Illuminate\Support\Facades\Auth;
use Illuminate\Support\Facades\DB;
use Illuminate\Http\HttpFoundation\Response;
class UserAuthenticateMiddleware extends Middleware {
public function handle($request, Closure $next) {
foreach(Session::all() as $key => $value)
{
$_SESSION[$key] = $value;
}
print_r($_SESSION);
}
}
但是,我收到以下错误:
Symfony \ Component \ Debug \ Exception \ FatalThrowableError (E_RECOVERABLE_ERROR)
Type error: Argument 1 passed to Illuminate\Session\Middleware\StartSession::addCookieToResponse() must be an instance of Symfony\Component\HttpFoundation\Response, null given, called in /home/dixon/php7esupport/esupport/vendor/laravel/framework/src/Illuminate/Session/Middleware/StartSession.php
这个问题的可能原因是什么?
答案 0 :(得分:0)
除非您没有展示您的整个功能,否则您将忘记return $next($request);
所以它会是这样的:
public function handle($request, Closure $next) {
foreach(Session::all() as $key => $value){
$_SESSION[$key] = $value;
}
return $next($request);
}