我正在使用auth組件,並且我不希望登錄頁面在用戶登錄後纔可訪問,只能由匿名用戶訪問。我可以在我的登錄方法中完成此操作?我已經試過這樣:CakePHP驗證組件:如何檢查某人是否已登錄?
if (isset($this->Auth->user('id')) {
$this->redirect('/profile/');
}
但我得到以下錯誤:
Fatal error: Can't use method return value
我正在使用auth組件,並且我不希望登錄頁面在用戶登錄後纔可訪問,只能由匿名用戶訪問。我可以在我的登錄方法中完成此操作?我已經試過這樣:CakePHP驗證組件:如何檢查某人是否已登錄?
if (isset($this->Auth->user('id')) {
$this->redirect('/profile/');
}
但我得到以下錯誤:
Fatal error: Can't use method return value
if ($this->Session->check('Auth.User')){
$this->redirect('/profile/');
}
非常感謝:) – geoffs3310 2011-01-31 14:46:54
爲了將來的參考,這裏的主要錯誤是由於對非變量的東西使用了`isset()`。此外,還有一個缺失的結束括號。 – 2012-10-11 00:24:19