'accounts_web_user', 'sub' => self::SUB_ACCOUNT_PREFIX . $account->id, ]; if ($session === null) { // If we don't remember a session, the token should live longer // so that the session doesn't end while working with the account $payloads['exp'] = time() + 60 * 60 * 24 * 7; // 7d } else { $payloads['jti'] = $session->id; } return Yii::$app->tokens->create($payloads); } }