Yii2 login from database
Create users table CREATE TABLE `users` ( `id` bigint(20) unsigned NOT NULL AUTO_INCREMENT, `email` varchar(255) DEFAULT NULL, `password_hash` varchar(255) DEFAULT NULL, PRIMARY KEY (`id`), KEY `email` (`email`) USING BTREE ); Create Users Model While you are at Gii, you should create search model too. Add the following namespaces in Users model class use yii\base\NotSupportedException; use yii\db\ActiveRecord; use yii\helpers\Security; use yii\web\IdentityInterface; Implements the IdentityInterface interface class with Users model class class Users extends \yii\db\ActiveRecord implements IdentityInterface Then add all the inherited functions from yii\web\IdentityInterface . See https://www.yiiframework.com/doc/api/2.0/yii-web-identityinterface Add function validatePassword in model/Users.php. /** * Validates password ...