User authentication

Hi,

I am using the standard user login / authentication provided by Yii, and I have got it so that a user can login.

I want to know how to know when a user is logged in so I can use it in my view files, like only display certain things to users when they are logged in.

I also noticed that there are three levels of access, guest, normal, admin. I have not actually implemented any "admin" into my application so what is all this "admin" about.

Generally this is done via the database tables, no?

Also I noticed can do user permissions for you based on this, can Yii’s user permissions still be used based on the value in the database? Rather than just guest, normal, admin?

For check if a user is logged in, uses




Yii::app()->user->isGuest



It retur true id the user is not logged.

The 3 level of authentication of Gii generated code are just a sample, not very usable.

The first is not logged in, the second is logged in, and the third is a user that has username admin.

If you need more complex permission setting, check RBAC in thedefinitive guide.

RBAC can manage permission on database.

There have been also lot of discussion about RBAC in the last time, you can read a lot about it.