private function encodeUserSessionResponse(UserSessionResponseInterface $action_result, ServerRequestInterface $request, ResponseInterface $response)
    {
        if ($action_result->getAuthenticatedWith() instanceof  SessionInterface) {
            $response = $this->getCookiesProvider()->set($request, $response, $this->getUserSessionIdCookieName(), $action_result->getAuthenticatedWith()->getSessionId(), [
                'ttl' => 1209600,
                'http_only' => true,
            ])[1];
        }

        return $this->encodeArray($action_result->toArray(), $response);
    }