如何在 CakePHP 3 中使用带有身份验证的“记住我”cookie?我在控制器中使用了以下代码:
if ($this->request->data['data']['rememberMe'] == "on") {
$cookie = array();
$cookie['username'] = $this->request->data['username'];
$cookie['password'] = $this->request->data['password'];
$this->request->Cookie->write('rememberMe', $cookie, true, "1 week");
unset($this->request->data['rememberMe']);
}
并得到错误:
在非对象上调用成员函数 write()