我UserController.php已注销功能,看起来像这样
function logout()
{
$this->Session->destroy('User');
$this->Session->setFlash('You\'ve successfully logged out.');
var_export($this->Session->read('User'));
//$this->redirect('login');
}
我认为用户/ index.ctp
<?php echo $this->Html->link('Logout', array('controller' => 'users', 'action' => 'logout')); ?>
当我点击“注销”的var_export仍显示所有用户数据,如果我回去用户/ index.ctp它仍然显示我,即使我在我的UserController.php如果用户设置我检查该网页
function beforeFilter()
{
$this->__validateLoginStatus();
}
function __validateLoginStatus()
{
if($this->action != 'login' && $this->action != 'logout')
{
if($this->Session->check('User') == false)
{
$this->redirect('login');
}
}
它不重定向到登录页面,只是把我带到索引页面。 }
$ this-> Session-> destroy('User');它也将起作用.. – 2012-06-14 12:03:13