public static void setCookie(HttpServletRequest request, HttpServletResponse response,
            String name, String value, int maxAge)
    {
        // Check to make sure the new value is not null (appservers like Tomcat
        // 4 blow up if the value is null).
        if (value == null) {
            value = "";
        }
        String path = request.getContextPath() == null ? "/" : request.getContextPath();
        if ("".equals(path)) {
            path = "/";
        }
        Cookie cookie = new Cookie(name, value);
        cookie.setMaxAge(maxAge);
        cookie.setPath(path);
        cookie.setHttpOnly(true);
        response.addCookie(cookie);
    }
Stores a value in a cookie. This cookie will persist for the amount
specified in the {@code saveTime} parameter.

@see #setCookie(javax.servlet.http.HttpServletRequest,javax.servlet.http.HttpServletResponse,String,String)
@param request the servlet request.
@param response the servlet response.
@param name a name to identify the cookie.
@param value the value to store in the cookie.
@param maxAge the time (in seconds) this cookie should live.
xmppserver/src/main/java/org/jivesoftware/util/CookieUtils.java