5.2.5.9 user
The original text for this section has changed since it was translated. Please help resolve this difference. You can:
user(string $key = null)
user(string $key = null)
このメソッドは、現在認証しているユーザの情報を提供します。この情報はセッションから取得されます。例は次のとおりです。
if ($this->Auth->user('role') == 'admin') {
$this->flash('あなたは管理者権限でアクセスしています。');
}
if ($this->Auth->user('role') == 'admin') {$this->flash('あなたは管理者権限でアクセスしています。');}
このメソッドは、ユーザのセッションデータを全て取得するためにも使えます。
$data['User'] = $this->Auth->user();
$data['User'] = $this->Auth->user();
ユーザーがログインしていない場合、このメソッドは null を返します。


























