Cakephp注销不起作用


Cakephp LogOut Not work

我有一个大问题我有3个视图文件夹{管理员,教师,用户}并且在所有这些文件中都使用index.ctp和logout.ctp当我想注销时,url重定向到/dashboard我的appcontroller.php

    public $components = array(
    'Cookie',
    'Session',
    'Auth' => array(
        'loginRedirect' => array('controller' => 'users', 'action' => 'index'),
        'logoutRedirect' => array('controller' => 'users', 'action' => 'login')
    ));
// only allow the login controllers only
public function beforeFilter() {
    $this->response->disableCache();
    $this->Auth->allow('login','logout');
}

和我的routes.php

Router::connect('/', array('controller' => 'users', 'action' => 'login'));
/**
 * ...and connect the rest of 'Pages' controller's URLs.
 */
	Router::connect('/pages/*', array('controller' => 'pages', 'action' => 'display'));
Router::connect('/dashboard', array('controller' => 'users', 'action' => 'index'));
Router::connect('/login', array('controller' => 'users', 'action' => 'login'));
Router::connect('/logout', array('controller' => 'users', 'action' => 'logout'));
/**
 * Load all plugin routes. See the CakePlugin documentation on
 * how to customize the loading of plugin routes.
 */
	CakePlugin::routes();
/**
 * Load the CakePHP default routes. Only remove this if you do not want to use
 * the built-in default routes.
 */
	require CAKE . 'Config' . DS . 'routes.php';

并使用此功能在我的控制器中注销

  public function logout()
{
    $this->redirect($this->Auth->logout());
}

请帮我解决这个问题。tnx

只需在控制器中更换即可

public function logout()
{
    $this->Auth->logout();
    $this->redirect( '/dashboard' );
}

它将完美地工作。