【发布时间】:2016-03-03 23:02:17
【问题描述】:
执行此代码时出现错误 我的错误是在布尔值上调用成员函数 read() 这是函数登录的代码:
public function login()
{
if ($this->request->is('post')) {
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
if ($this->request->data['rememberMe']=="on") {
$cookie = [];
$cookie['username'] = $this->request->data['email'];
$cookie['password'] = $this->request->data['password'];
$this->Cookie->write('rememberMe', $cookie, true, "1 week");
unset($this->request->data['rememberMe']);
}
if (empty($this->data)) {
$cookie = $this->Cookie->read('rememberMe');
if (!is_null($cookie)) {
$this->request->data = $cookie;
$user = $this->Auth->identify();
if ($user) {
$this->Auth->setUser($user);
$this->redirect($this->Auth->redirectUrl());
} else {
$this->Cookie->destroy('rememberMe'); # delete invalid cookie
$this->Session->setFlash('Invalid cookie');
$this->redirect('login');
}
}
}
return $this->redirect($this->Auth->redirectUrl());
}
else
$this->Flash->error(__("Nom d'utilisateur ou mot de passe incorrect, essayez de nouveau."));
}
}
我改变了data['rememberMe']=="on"data['rememberMe']==1`
显示另一个错误 Call to a member function write() on boolean
【问题讨论】:
标签: login cakephp-3.x