public static function setCookie(
        ResponseInterface $response,
        /*# string */ $name,
        /*# string */ $value = null,
        /*# int */ $ttl = null,
        /*# string */ $path = null,
        /*# string */ $domain = null,
        /*# bool */ $secure = false,
        /*# bool */ $httponly = true
    )/*# : ResponseInterface */ {
        $cookie = urlencode($name) . '=' . urlencode($value);

        self::addExpire($cookie, $ttl);

        self::addDomain($cookie, $domain);

        self::addPath($cookie, $path);

        self::addSecure($cookie, $secure);

        self::addHttpOnly($cookie, $httponly);

        return $response->withAddedHeader('Set-Cookie', $cookie);
    }