Iam新cakephp和iam使用身份验证我的登录utiities ...我想重定向到登录页面incase我的会话experies为我所有的行为...我写代码像\如何重定向到登录页面是会话experies
public function index() {
if(!$this->Session->read('username'))
$this->logout();
$this->set('users', $this->paginate());
}
但我所有的行动,如加(),编辑()......每次我需要检查的会话变量...如果我写这样
public function __construct()
{
if(!$this->Session->read('username'))
$this->logout();
}
在__construct条件
它给我错误像
Error: Call to a member function read() on a non-object
任何人都可以建议我
尝试[认证组件](http://book.cakephp.org/2.0/en/core-libraries/components/authentication.html) – 2013-03-13 06:42:07