【问题标题】:Missing logout page in view/users in cakephpcakephp 中的视图/用户中缺少注销页面
【发布时间】:2016-05-18 12:00:54
【问题描述】:

我正在研究 cakephp,当点击注销按钮 url 转到其他地址 http://demo4sbc.com.Because 时,视图/用户中没有 logout.ctp,所以任何人都可以告诉我 logout.ctp 页面的编码。

【问题讨论】:

  • 请在 usersController 中发布您的 logout() 操作代码
  • 你在 UsersController 中创建了注销方法吗?
  • 函数注销() { $this->Session->destroy(); $this->redirect($this->Auth->logout()); } 公共函数 google_logout(){ $this->Session->destroy(); $this->Session->delete('Glogin'); header('位置:google.com/accounts/Logout?continue=https://…); $this->redirect($this->Auth->logout()); }

标签: cakephp model-view-controller


【解决方案1】:

您不需要logout.ctp 视图,只需检查您在注销后重定向用户的位置

这个怎么样:

UsersController.php

public function logout() {

    $this->Session->destroy();

    return $this->redirect($this->Auth->logout());
}

AppController.php

class AppController extends Controller
{

    public function initialize()
    {
        parent::initialize();
        $this->loadComponent('Auth', array(
            'authenticate' => array(
                'Form' => array('fields' => array('username' => 'email', 'password' => 'password'))
            ),
            //Controller and Action where you want redirect users after login
            'loginRedirect' => array(
                'controller' => 'Users',
                'action' => 'index'
            ),
            //Controller and Action where you want redirect users after logout
            'logoutRedirect' => array(
                'controller' => 'Pages', 
                'action' => 'home', 
            ),
        ));

    }

【讨论】:

  • 非常感谢我得到了我的错误,现在如果我在数据库中有一些数据并且搜索结果是空白页...为什么
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-05-16
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多