public static Cookie getCookie(HttpServletRequest request, String cookieName) {
        Cookie cookie = null;
        for (Cookie curCookie : request.getCookies()) {
            if (cookieName.equals(curCookie.getName())) {
                cookie = curCookie;
                break;
            }
        }
        return cookie;
    }