public static void setCookieValue(HttpServletResponse response, String cookieName,
            String cookieValue, int expireInHour) {
        Cookie cookie = new Cookie(cookieName, cookieValue);
        if (expireInHour > 0) {
            cookie.setMaxAge(60 * 60 * 24 * expireInHour);
        } else {
            cookie.setMaxAge(60 * 60 * 24);
        }
        response.addCookie(cookie);
    }
public static void setCookieValue ( HttpServletResponse response , String cookieName , String cookieValue , int expireInHour ) { Cookie cookie = new Cookie ( cookieName , cookieValue ) ; if ( expireInHour > 0 ) { cookie . setMaxAge ( 60 * 60 * 24 * expireInHour ) ; } else { cookie . setMaxAge ( 60 * 60 * 24 ) ; } response . addCookie ( cookie ) ; }
设置cookie值

@param response
返回response
@param cookieName
cookie名
@param cookieValue
cookie值
@param expireInHour
过期时间