开发者

CakePHP: Call to a member function setFlash() on a non-object

I get the following error when trying to logout of my CakePHP app:

Notice (8): Undefined property: UsersController::$Session [APP/controllers/users_controller.php, lin开发者_运维问答e 75]
Fatal error: Call to a member function setFlash() on a non-object in /Users/cameron/Sites/cakeapp/app/controllers/users_controller.php on line 75

This is the code for lines 74, 75 and 76:

function logout() {
    $this->Session->setFlash('Good-Bye');
    $this->redirect($this->Auth->logout());
}


It looks like you don't have the Session component loaded in your Users controller.

The Session component should be loaded by default, but if you've set the components array in AppController this will overwrite the defaults.

This means that if you have

var $components = array();

in your AppController, make sure the Session component is included there:

var $components = array('Session');

Alternatively, you can load the Session component in your Users controller if you don't want to use it app-wide.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜