CakePhp:用户登录功能

CakePhp:用户登录功能,cakephp,Cakephp,} 这是RegistersController页面。按如下所示更改您的表单- public function login(){ if($this->Auth->loggedIn()){ $this->redirect(array('action' => 'home')); } if($this->request->is('post')){ if ($this->Auth->login($this->request->data)

}
这是RegistersController页面。

按如下所示更改您的表单-

public function login(){
 if($this->Auth->loggedIn()){
 $this->redirect(array('action' => 'home'));
 }
 if($this->request->is('post')){
 if ($this->Auth->login($this->request->data)) {
 $this->Session->write('Register',$this->request->data);
 $this->redirect(array('controller' => 'Registers','action' => 'home'));
 } else {
 $this->Session->setFlash(__('Username or password is incorrect'));
 }
 }
继续下面的链接了解详细信息-

我建议您从浏览器中销毁会话,然后执行此代码。这是正确的代码吗?是的,看起来不错。我可以知道蛋糕的版本吗?如果$this->Auth->login$this->request->data{}你是2031号,谁做错了。糟糕。这等于我们不使用密码登录。请仔细阅读这些文件!我确实喜欢这样做,但我希望我们提供正确的细节,将显示错误消息。
public function login(){
 if($this->Auth->loggedIn()){
 $this->redirect(array('action' => 'home'));
 }
 if($this->request->is('post')){
 if ($this->Auth->login($this->request->data)) {
 $this->Session->write('Register',$this->request->data);
 $this->redirect(array('controller' => 'Registers','action' => 'home'));
 } else {
 $this->Session->setFlash(__('Username or password is incorrect'));
 }
 }
<?php echo $this->Form->create('Register'); ?>
<?php echo $this->Form->input('User.username'); ?>
<?php echo $this->Form->input('User.password'); ?>
<?php echo $this->Form->end('Login'); ?>  
$this->Session->write('Register',$this->request->data); this line is not needed any more.