I am using the below code in the accessRules() function to match the roles of the logged in user. The role is set during the authentication process using
$this->setState(‘role’, $record->role);
The code in the accessRules() function is:
$role="";
if(Yii::app()->user->getId()===null)
{
$role="guest";
}
else
{
$role=Yii::app()->user->role;
}
return array(
array('allow', 'actions'=>array('index','view'),
'users'=>array('*'),
),
);
This code is working fine on my local machine but when I upload it to the server it gives me Use of undefined constant guest - assumed ‘guest’ error. What is the reason for this and how can I resolve this. Thanks!!!
FYI: The local machine is windows 7 and server is LINUX.