chapter 7, CUserIdentity pg 167

I’ve looked at the CUserIdentity class, name and id are not explicitly defined properties (as in class variables).

Edit:

I’ve just looked at it again. I think you misworded it? They’re actually defined methods? Or am I wrong?

Code in the CUserIdentity class.


	public function getId()

	{

		return $this->username;

	}


	public function getName()

	{

		return $this->username;

	}

Looking at it over again, I believe you just overloaded the getId function.

[s]Edit:

Different approach? What was the other previous approaches we have done?[/s] <-- sorry I jumped the gun on that one


Oh, I got it now. I guess you were trying to say that since the parent class have a function getId, we’ve just have to overload it in the child. Whereas the lastLoginTime is different because the parent class doesn’t have a function for this, so we had to add it to session.

Am I correct in my assessment?

Yes, this is more or less on the right track. I agree better phrasing could have been used.

The basic idea is that the reason that we use different approaches to save id and lastLoginTime is because id is already a pre-defined property that is recognized by CWebUser (and it is set by an explicit call to the getId() method of the Identity class during login). If we want to store information beyond id and name, then we need to use setState(), as was done with lastLoginTime.

Hope this helps, and sorry for any confusion.

Thank you ^^.