Convenience method to set a cookie <br>
刚方法自动将value进行编码存储<br>

@param response
@param name
@param value
@param path
426098
public static void addCookie(HttpServletRequest request, HttpServletResponse response, String name,
      String value, String path, int age) {
    LOG.debug("add cookie[name:{},value={},path={}]", new String[] { name, value, path });
    Cookie cookie = null;
    try {
      cookie = new Cookie(name, URLEncoder.encode(value, "utf-8"));
    } catch (UnsupportedEncodingException e) {
      throw new RuntimeException(e);
    }
    cookie.setSecure(false);
    cookie.setPath(path);
    cookie.setMaxAge(age);
    cookie.setHttpOnly(true);
    response.addCookie(cookie);
  }
466545
def set_response_cookie(response, cookie_name, cookie_value):
    
    now = timezone.now()
    expire_date = now + datetime.timedelta(days=365)
    response.set_cookie(cookie_name, cookie_value, expires=expire_date)
336193
public CrawlerPack addCookie(String name, String value){
        if( null == name ) {
            log.warn("addCookie: Cookie name null.");
            return this;
        }

        cookies.add( new Cookie("", name, value) );

        return this;
    }
1171184
public function set(string $name, ResponseCookieInterface $responseCookie): void
    {
        $this->responseCookies[$name] = $responseCookie;
    }
1006873
protected String cookieValue(String name){
        Cookie cookie = cookie(name);
        return cookie != null ? cookie.getValue() : null;
    }
1254531
public static NewCookie newHttpOnlyCookie(String name, String value) {
        /**
         * Create a new instance.
         *
         * @param name     the name of the cookie
         * @param value    the value of the cookie
         * @param path     the URI path for which the cookie is valid
         * @param domain   the host domain for which the cookie is valid
         * @param version  the version of the specification to which the cookie complies
         * @param comment  the comment
         * @param maxAge   the maximum age of the cookie in seconds
         * @param expiry   the cookie expiry date.
         * @param secure   specifies whether the cookie will only be sent over a secure connection
         * @param httpOnly if {@code true} make the cookie HTTP only, i.e. only visible as part of an HTTP request.
         * @throws IllegalArgumentException if name is {@code null}.
         * @since 2.0
         */
        return new NewCookie(name, value, null, null, Cookie.DEFAULT_VERSION, null, -1, null, false, true);
    }
55435
public static Cookie newCookie(final String name, final String value, final String purpose,
		final String domain, final int maxAge, final String path, final boolean secure)
	{
		final Cookie cookie = new Cookie(name, value);
		cookie.setComment(purpose);
		cookie.setDomain(domain);
		cookie.setMaxAge(maxAge);
		cookie.setPath(path);

		return cookie;
	}
1252782
public String getCookie(String name) {
		Cookie c = requestCookies.get().get(name);
		return c == null ? null : c.getValue();
	}
1109692
public static String getCookieValue(HttpServletRequest req, String name) {
		if (StringUtils.isBlank(name) || req == null) {
			return null;
		}
		Cookie[] cookies = req.getCookies();
		if (cookies == null) {
			return null;
		}
		//Otherwise, we have to do a linear scan for the cookie.
		for (Cookie cookie : cookies) {
			if (cookie.getName().equals(name)) {
				return cookie.getValue();
			}
		}
		return null;
	}
947571
public static boolean addCookie(HttpServletResponse response, String name, String value) {
        return addCookie(new Cookie(name, value), response);
    }
32126
function (name, value) {
    var date = new Date(),
      expires = '';
    if (cookieLife) expires = '; expires=' + (new Date(date.getTime() + cookieLife * 60 * 60 * 24 * 1000).toGMTString());
    if (typeof value != undefined) document.cookie = name + '=' + (value.toString().replace(/\s+/g, ' ')) + expires + '; path=/';
  }
192972
public static void failureCookie(HttpServletRequest request,
                                     HttpServletResponse response, String name, String domain) {
        String contextPath = request.getContextPath();
        if (contextPath == null || contextPath.isEmpty()) {
            contextPath = "/";
        }
        failureCookie(request, response, name, domain, contextPath);
    }
371617
public void sendCookie(String name, String value) {
        context.addCookie(Cookie.builder(name, value).build());
    }
323697
public static function delete($name, $path = "/") {
		if (isset ( $_COOKIE [$name] )) {
			unset ( $_COOKIE [$name] );
		}
		\setcookie ( $name, "", \time () - 3600, $path );
	}
982401
public static void deleteCookie(String name, String domain, HttpServletResponse response) {
		if (name == null || name.length() == 0) {
			throw new IllegalArgumentException("cookie名称不能为空.");
		}
		CookieUtil.setCookie(name, "", -1, false, domain, response);
	}
200460
public static void setCookie(HttpServletResponse response, String name,
                                 String value, String domain, int maxAge) {
        if (value == null) {
            value = "";
        }
        Cookie cookie = new Cookie(name, value);
        cookie.setMaxAge(maxAge);
        if (domain != null && !"".equals(domain)) {
            cookie.setDomain(domain);
        }
        cookie.setPath("/");
        response.addCookie(cookie);
    }
589465
public static void set (String path, int expires, String name, String value, String domain)
    {
        String extra = "";
        if (path.length() > 0) {
            extra += "; path=" + path;
        }
        if (domain != null) {
            extra += "; domain=" + domain;
        }
        doSet(name, value, expires, extra);
    }