When Is Cwebuser->Afterlogin() Called For Cookie Logins?

I’m using Yii v1.1.14. I extended CWebUser with a custom WebUser class and overrided the afterLogin function. This takes a $fromCookie parameter, which works great for adding special logic for cookie-based logins, since those bypass the SiteController login action. However, this doesn’t seem to be called until after I reference Yii::app()->user in my own code. I would have thought that this event would be raised automatically. Am I missing something?

You are right, the method afterLogin is called by CWebUser::restoreFromCookie in CWebUser::init();

So you have to reference Yii::app()->user.

This will be done by calling if(Yii::app()->user->isGuest) …

used in accessRules or when you decide to show a login form

OK, great. It’s easy to make it work, just wanted to make sure I wasn’t missing something. Thanks!