Yii2.0 Framework

How to Get Logged In User Details in Yii2

In this tutorial, we will show how you can get the logged in user details in Yii2. After the successful login the user information will be stored in Yii::$app->user->identity variable.

The authenticated user identity information can be retrieved via Yii::$app->user->identity.

Get Logged In User Details:

The below php script will return the logged in user details:

//To get whole logged user data
$user = \Yii::$app->user->identity;
//To get id of logged user
$userId = \Yii::$app->user->identity->id;
//To get username of the logged in user



(Visited 71 times, 1 visits today)
Chandra Kumar

Hello World, I am Chandra Kumar from New Delhi, India. I am professionally developer, programmer and blogger. I am the founder of WebShouters.com.

0 Comment

Leave a Comment

Your email address will not be published. Required fields are marked *