Question: yii2 how to get user id?
Answer: Logged in user information will be stored in Yii::$app->user->identity variable. The authenticated user identity information can be retrieved via Yii::$app->user->identity.