How to create Module based Login

Lets say we have 3 modules (customer, user, admin) in an application and we need, separate logins for each module.

We can achieve this by adding a prefix to the name of session variable for each module.

Lets take 'admin' module:

Inside your admin/AdminModule.php file, add the following lines to the 'init' function



            'errorHandler' => array(
                'errorAction' => 'admin/default/error',
            'user' => array(
                'class' => 'CWebUser',
                'stateKeyPrefix' => '_admin',
                'loginUrl' => Yii::app()->createUrl($this->getId() . '/default/login'),