Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Yii Framework get user data

Tags:

php

yii

yii2

How can I get currently online user data with all the parameters from the database? Right now I get it's ID by using this:

echo Yii::$app->user->getId();

Can I reach other data somehow or do I have to create a function which gets all the information by the user ID?

like image 334
The50 Avatar asked Jan 18 '26 02:01

The50


1 Answers

You can access to all the identity values in this way

this for username

Yii::$app->user->identity->username

check for your User models for others attributes

http://www.yiiframework.com/doc-2.0/guide-security-authentication.html

http://www.yiiframework.com/doc-2.0/yii-web-identityinterface.html

http://www.yiiframework.com/doc-2.0/yii-web-user.html

(and your User model of course)

like image 68
ScaisEdge Avatar answered Jan 20 '26 17:01

ScaisEdge



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!