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