Yii2前后台分开用户表

前台:main.php

    'components' => [
        'user' => [
            'identityClass' => 'common\models\User',
            'enableAutoLogin' => true,
'idParam' => '__user',
'identityCookie' => ['name' => '__user_identity', 'httpOnly' => true],
'loginUrl' => ['site/login'],
        ],

后台:main.php

    'components' => [
        'user' => [
            'identityClass' => 'common\models\Admin',
            'enableAutoLogin' => true,
'idParam' => '__admin',
'identityCookie' => ['name' => '__admin_identity', 'httpOnly' => true],
'loginUrl' => ['site/login'],
        ],


前台不变,后台增加LoginFormAdmin.php,Admin.php,验证部分使用$model = new LoginFormAdmin();

你可能感兴趣的:(yii)