Iamは、ログインユーティリティにauthを使用するcakephpとiamを初めて使用します...すべてのアクションのセッション経験がある場合は、ログインページにリダイレクトしたい...次のようなコードを記述しました\
public function index() {
if(!$this->Session->read('username'))
$this->logout();
$this->set('users', $this->paginate());
}
しかし、add()、edit()などのすべてのアクションについて...セッション変数をチェックする必要があるたびに...条件を__constructに次のように記述した場合
public function __construct()
{
if(!$this->Session->read('username'))
$this->logout();
}
それは私に次のようなエラーを与えます
Error: Call to a member function read() on a non-object
誰かが私を提案できますか