code: protected static Cookie getCookie(HttpServletRequest request, String name) {
  
          Cookie[] cookies = request.getCookies();
          for (int i = 0; (cookies != null) && (i < cookies.length); i++) {
              if (name.equalsIgnoreCase(cookies[i].getName())) {
                  return cookies[i];
              }
          }
          return new Cookie(name, "");
      }
docs: Returns the cookie with the given name, if not cookie is found a new one is created.<p>
  
  @param request the current request
  @param name the name of the cookie
  
  @return the cookie