Yii Yii::app ()->user->name If you do not set the default is guest, how do I customize this guest?

Source: Internet
Author: User
Prerequisite default global language to set to Chinese
Take the framework installation as an example:
For example, after logging in User->name;? > will display the default admin or demo,
But if you don't log in User->name;? > will show guest, how do I set this guest?
Ask for advice?


Reply to discussion (solution)

Guest is the guest's meaning, that is, unregistered users

You can find it in the login processing code

Class Cwebuser extends Capplicationcomponent implements iwebuser{public        $guestName = ' Guest ';        ...

There should be a webuser in the protected/components to inherit, to change his own
I do not know whether to use the native Yii, to give you a reference

Thank you, 2l code accurate positioning, but there is a problem, in the Cwebuser directly change is not very good ah? Can you give a thought to solve the idea?
Ask for advice?

If you don't think it's a good thing to change directly, create a class yourself, inherit Cwebuser, and make Yii::app ()->user the class you created for yourself. You can then modify the class you created yourself.

Well, it's basically a 4L approach.

Instead of defining a class, you can specify the property $guestname=xx when you set the user directly at the configuration file, and all properties are redefined in the configuration file. The program is instantiated according to your configuration

Thank you, two ways to try

  • Contact Us

    The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

    If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

    A Free Trial That Lets You Build Big!

    Start building with 50+ products and up to 12 months usage for Elastic Compute Service

    • Sales Support

      1 on 1 presale consultation

    • After-Sales Support

      24/7 Technical Support 6 Free Tickets per Quarter Faster Response

    • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.