如何杀死cakephp中的会话

pus*_*hpa 2 cakephp cakephp-1.3

我在登录模块上工作.在注销功能中,我按如下方式编写代码,首先终止会话,然后将其重定向到主页.它工作正常但会话没有破坏.如果有人知道请帮助我这是我的登录和注销代码片段:

function login()
{

   if(!empty($this->data))
    { 

       $user1= $this->User->validateLogin($this->data['User']);

         if($user1== true)
        {

               $this->redirect(array('action'=>'index'));
        }
        else
        {
                $this->Session->setflash('Login failed, Try again'); 
         }
    }
}

function logout()
{

    $this->Session->delete('User');
    $this->redirect('/users/index');
}
Run Code Online (Sandbox Code Playgroud)

我得到的信息是,我必须保留标题信息,下面是我的代码片段:$ this-> header("Cache-Control:no-cache,no-store,must-revalidate"); $ this-> header("Expires:Mon,1970年1月1日00:00:00 GMT");

但我没有得到我的控制器的哪一部分我应该粘贴这个代码?请帮我....

sam*_*han 8

试试$ this-> Session-> destroy(); destroy方法将删除会话cookie和存储在临时文件系统中的所有会话数据.检查此链接