我正在使用带有自动登录组件的 CakePHP 2x。问题是,我可以写这些东西,但是我不确定如何实现它来读取和授权。当用户到达该页面时,他的浏览器中仍然有 cookie,但是,我该如何授权呢?
我的登录脚本:
public function login() {
if ($this->Auth->user('id')) {
$this->redirect(array('action' => 'dashboard'));
}
if($this->request->data['User']['auto_login']):
$this->AutoLogin->write($this->request->data['User']['username'],
$this->request->data['User']['password']);
endif;
if ($this->request->is('post')) {
if ($this->Auth->login( )) {
//$this->redirect(array('controller' => 'users', 'action' => 'dashboard'));
return $this->redirect($this->Auth->redirect( ));
}
else
{
$this->Session->setFlash(__('Username or Password is incorrect'), 'default', array( ), 'auth');
}
}