如何设置Yii :: app() – > user-> name

我试过了
public function getName()
{
    return 'TEST';
}

在UserIdentity.PHP但它似乎没有改变Yii :: app() – > user-> name的值

在您定义的UserIdentity类中,您需要使用setState(name,value)方法设置新状态.

例如,在方法中验证用户是否良好:

//if the user is good (good login and good password)
$this->_id=$record->id;
$this->setState('name',$record->name);
$this->errorCode=self::ERROR_NONE;

然后,您将能够调用Yii :: app() – > user-> name

> A complete example in the Yii guide
> The setState() documentation

相关文章

统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...
前言 之前做了微信登录,所以总结一下微信授权登录并获取用户...
FastAdmin是我第一个接触的后台管理系统框架。FastAdmin是一...
之前公司需要一个内部的通讯软件,就叫我做一个。通讯软件嘛...
统一支付是JSAPI/NATIVE/APP各种支付场景下生成支付订单,返...