code: public static Cookie findCookie(HttpServletRequest request, String name) {
          if (request != null) {
              Cookie[] cookies = request.getCookies();
              if (cookies != null && cookies.length > 0) {
                  for (Cookie cookie : cookies) {
                      if (cookie.getName().equals(name)) {
                          return cookie;
                      }
                  }
              }
          }
          return null;
      }
docs: find cookie from request
  @param request current request
  @param name cookie name
  @return cookie value or null