I have the following code in front-end, to check if the user is logged in module admin as admin.
$u = Yii::app()->user;
if (is_object($u)) {
// under re-initialization this might not exists, that's why the additional check
$_stateKeyPrefix = $u->getStateKeyPrefix();
}
/*
* We initilize admin module, and once this is done in Yii::app()->user we have the admin state.
* We do the check to see if the admin is logged in.
* In the end, we reset the state key prefix to its original value,
* and this change changes Yii::app()->user to the state we had on front-end.
*/
$m = Yii::app()->getModule('admin');
if(Yii::app()->user->isGuest) exit('You must log in as admin first');
// other calls before this might have initialised other modules, who might have changed the prefix
if (is_object($u)) {
$u->setStateKeyPrefix($_stateKeyPrefix);
}
this works fine to check if the current PC has a session in admin also, if the admin is on the same domain eg:
but doesn’t work if the admin is setup as a subdomain
What options I have here to verifiy properly if the user is logged in as admin?