Difference between #10 and #11 of
How to login from different tables in Yii2

Changes

Title unchanged

How to login from different tables in Yii2

Category unchanged

How-tos

Yii version unchanged

2.0

Tags unchanged

authentication,login,different table name,multiple login

Content changed

The Problem: Yii2 utilizes by default UserIdentity configured in config/web.php for connection, this object apply one table to authentication ('identityClass' => 'app\painel\models\User'). How to authentication from diferent tables?
Solution:
Create instances in web.php to uses UserIdentify.
[...]
'loginUrl' => ['dashboard-teacher/login'],
'identityCookie' => [
'name' => '_pa
inelTeacher',
]
],
[...]
```

Model scho
lol:

```php
[...]
```php
<?php if (!\Yii::$app->scholl->isGuest):?>
<h1>My scho
lol Name: <?=\Yii::$app->scholl->identity->name?>
<?php endif;?>

<?php if (!\Yii::$app->teacher->isGuest):?>
<h1>Teacher Name: <?=\Yii::$app->teacher->identity->name?>
<?php endif;?>
[...]
5 0
6 followers
Viewed: 64 385 times
Version: 2.0
Category: How-tos
Written by: AndroideLP
Last updated by: lenovo
Created on: Apr 3, 2018
Last updated: 4 years ago
Update Article

Revisions

View all history