Authenticate Every Page

I’ve created an application in Yii where you can do a simple login. Once I am signed in, I am basically in as long as my session persist. However, I would like to do a status check on every page visit for a user to ensure that he still has permissions to access the site (e.g. if the user gets inactived then he should not stay logged in).

What is the best approach to authenticate the user on every page; is it on Controller level, Controller method level, View level or some other way? Ideally it would be the easiest if the check is included once per controller. Can you please advise how you have done this?

I’m not sure, but i think there is a place in the config file that sets how long time a user is logged in since the last time he was active (and i think the default is one hour).

To authenticate the user i’m using something like this code in my controller actions:



			throw new CHttpException(401);


EDIT: You should check out this: