class CookieUtil {

    public static String removeCookie(String cookieHeader, String name) {
        StringBuilder sb = new StringBuilder();

        int counter = 0;
        boolean changed = false;
        if (StringUtils.isNotBlank(cookieHeader)) {
            for (final String cookie : cookieHeader.split(";")) {
                final String[] cookieParts = cookie.split("=", 2);
                if (StringUtils.equals(StringUtils.trim(cookieParts[0]), name)) {
                    changed = true;
                    continue;
                }

                if (counter++ > 0) sb.append(';');
                sb.append(cookie);
            }
        }

        if (!changed) return cookieHeader;
        return sb.toString();
    }

}