Patricia Beier Patricia Beier - 1 year ago 88
PHP Question

Get the name of the user in yii2

How can I get the name of the logged-in-user in yii2?
I can get the user-id with


and I know that I could find the name in the database but I want a direct way.
The name-column in the database has the name "username", but


doesn't work and


doesn't work either.

Answer Source

On login the user information will be stored in Yii::$app->user->identity variable.

For more information have a read through the User Authentication documentation in the official guide.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download