Cakephp 无法在PHP 4.1中对用户进行身份验证

Cakephp 无法在PHP 4.1中对用户进行身份验证,cakephp,cakephp-4.x,Cakephp,Cakephp 4.x,我已经设置了最新的蛋糕ph设置,当我尝试登录用户时,它会给我这个错误 传递给Cake\Http\Session::\u overwrite()的参数1必须是数组类型,给定为null 我的代码是 $user = $this->Auth->identify(); if ($user) { $this->Auth->setUser($user); return $this->redirect($this->Auth->redirectUrl()

我已经设置了最新的蛋糕ph设置,当我尝试登录用户时,它会给我这个错误

传递给Cake\Http\Session::\u overwrite()的参数1必须是数组类型,给定为null

我的代码是

$user = $this->Auth->identify();
if ($user) {
    $this->Auth->setUser($user);
    return $this->redirect($this->Auth->redirectUrl());
} else {
    $this->Flash->error(__('Username or password is incorrect'));
}

当我选中$user时,它会给我标识的用户,但随后它会给我上述错误。

在供应商的覆盖函数中删除Session.php中的数组类型。如下代码所示。 这是我的工作。 /供应商/cakephp/cakephp/src/Http

protected function _overwrite( &$old, array $new): void{
 if (!empty($old)) {
  foreach ($old as $key => $var) {
   if (!isset($new[$key])) { 
    unset($old[$key]);
   }
  }
 }
 foreach ($new as $key => $var) {
   
   $old[$key] = $var;


 }

}

请阅读并遵循@Salines感谢您的文档,但我已经提到了这一点,但找不到解决方案每当您收到错误时,请发布完整的错误消息,并包括相关的stacktrace(您可以在您的CakePHP
/logs/
中找到它们)!在您的特定情况下,您应该检查所有错误(清除日志、运行代码、检查日志),因为您的问题意味着
$\u会话
superglobal为
null
,这意味着会话可能未正确启动,这可能是由于其他错误造成的。