/** * This method is called after the user is successfully logged in. * The default implementation will trigger the [[EVENT_AFTER_LOGIN]] event. * If you override this method, make sure you call the parent implementation * so that the event is triggered. * @param IdentityInterface $identity the user identity information * @param boolean $cookieBased whether the login is cookie-based * @param integer $duration number of seconds that the user can remain in logged-in status. * If 0, it means login till the user closes the browser or the session is manually destroyed. */ protected function afterLogin($identity, $cookieBased, $duration) { if (!$cookieBased) { $identity->last_login = date('Y-m-d H:i:s', time()); } if (!$this->enableAutoLogin) { $identity->login_sess = session_id(); } if (!$cookieBased || !$this->enableAutoLogin) { $identity->save(); } $this->trigger(self::EVENT_AFTER_LOGIN, new UserEvent(['identity' => $identity, 'cookieBased' => $cookieBased, 'duration' => $duration])); }