I have a problem on getting a property from model User . Simply the code should get the type of user whether its admin or normal user then each of them redirect to their controllers . code at controller :
public function actionIndex()
{
if (Yii::$app->user->isGuest) {
return $this->render('index');
} else {
// Administrator
if (Yii::$app->session->get('user.type') == 1) {
return $this->redirect('admin');
//user
Yii::$app->session->get('user.type') == 2) {
return $this->redirect('normal-user');
}
else {
Yii::$app->user->logout();
return $this->refresh();
}
}
}
This type is from My database table and it only have two values "1" or "2" . when i check this its getting "0" don't know how .so it always logout() any suggestions might be not taken on my consideration !!!