protected String buildHeaderValue(String name, String value, String comment,
                                      String domain, String path, int maxAge, int version,
                                      boolean secure, boolean httpOnly, SameSiteOptions sameSite) {

        if (!StringUtils.hasText(name)) {
            throw new IllegalStateException("Cookie name cannot be null/empty.");
        }

        StringBuilder sb = new StringBuilder(name).append(NAME_VALUE_DELIMITER);

        if (StringUtils.hasText(value)) {
            sb.append(value);
        }

        appendComment(sb, comment);
        appendDomain(sb, domain);
        appendPath(sb, path);
        appendExpires(sb, maxAge);
        appendVersion(sb, version);
        appendSecure(sb, secure);
        appendHttpOnly(sb, httpOnly);
        appendSameSite(sb, sameSite);

        return sb.toString();

    }
Returns the Cookie's calculated path setting.  If the {@link javax.servlet.http.Cookie#getPath() path} is {@code null},
then the {@code request}'s {@link javax.servlet.http.HttpServletRequest#getContextPath() context path}
will be returned. If getContextPath() is the empty string or null then the ROOT_PATH constant is returned.

@param request the incoming HttpServletRequest
@return the path to be used as the path when the cookie is created or removed
web/src/main/java/org/apache/shiro/web/servlet/SimpleCookie.java