8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

CakePHP3でログイン情報をViewに表示する方法

Posted at
cake version 3.3.11

ViewにログインIDやアカウント名を表示したい時ってありますよね?
セッションにログイン情報が入っているので、セッションから値を表示します。
SessionHelperは使用すべきではないとのことなんで、request->session()を使った方法を載せておきます。

src/Template/Layout/default.ctp
...
ログインID <?=$this->request->session()->read('Auth.User.login_id')?>
アカウント名: <?=$this->request->session()->read('Auth.User.name')?>
...
8
10
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
8
10

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?