yii\web\User::sendIdentityCookie PHP Method

sendIdentityCookie() protected method

This method is used when [[enableAutoLogin]] is true. It saves [[id]], [[IdentityInterface::getAuthKey()|auth key]], and the duration of cookie-based login information in the cookie.
See also: loginByCookie()
protected sendIdentityCookie ( yii\web\IdentityInterface $identity, integer $duration )
$identity yii\web\IdentityInterface
$duration integer number of seconds that the user can remain in logged-in status.
    protected function sendIdentityCookie($identity, $duration)
    {
        $cookie = new Cookie($this->identityCookie);
        $cookie->value = json_encode([$identity->getId(), $identity->getAuthKey(), $duration], JSON_UNESCAPED_SLASHES | JSON_UNESCAPED_UNICODE);
        $cookie->expire = time() + $duration;
        Yii::$app->getResponse()->getCookies()->add($cookie);
    }