Creates and returns a JavaScript line that sets a cookie with the specified name and value. For example, a cookie name
of "test" and value of "123" would return {@code document.cookie="test=123;";}. Note: The name and value will be
HTML-encoded.
483660
public String getJavaScriptHtmlCookieString(String name, String value) {
        return getJavaScriptHtmlCookieString(name, value, null);
    }
1327416
function cookie(name, value, ttl, path, domain, secure) {
    if (arguments.length > 1) {
        let newCookie = name + '=' + encodeURIComponent(value) +
            (ttl ? "; expires=" + new Date(+new Date()+(ttl*1000)).toUTCString() : '') +
            (path   ? "; path=" + path : '') +
            (domain ? "; domain=" + domain : '') +
            (secure ? "; secure" : '');
        document.cookie = newCookie;
        return newCookie;
    }
    return decodeURIComponent((("; "+document.cookie).split("; "+name+"=")[1]||"").split(";")[0]);
}
469767
function set(name, value) {

        // if no value then remove
        if (!value) {
            remove(name);
            return;
        }

        if (localStorage) {
            try {
                localStorage.setItem(name, value);
            }
            catch (ex) {}
        }

        _.isFunction($cookies.put) ?
            $cookies.put(name, value, { domain: cookieDomain }) :
            $cookies[name] = value;

    }
623420
public static void setCookie(String name, String value, int maxAge, HttpServletRequest request, HttpServletResponse response) {
		boolean httpOnly = false;
		CookieUtil.setCookie(name, value, maxAge, httpOnly, request, response);
	}
1252987
function set(name, value, options) {
  options = options || {};
  var str = encode(name) + '=' + encode(value);

  if (null == value) options.maxage = -1;

  if (options.maxage) {
    options.expires = new Date(+new Date + options.maxage);
  }

  if (options.path) str += '; path=' + options.path;
  if (options.domain) str += '; domain=' + options.domain;
  if (options.expires) str += '; expires=' + options.expires.toUTCString();
  if (options.secure) str += '; secure';

  document.cookie = str;
}
446594
function getCookie(cookieName) {
  if (typeof window === 'undefined' || typeof document === 'undefined') {
    return '';
  }
  var name = cookieName + '=';
  var ca = document.cookie.split(';');
  for (var i = 0; i < ca.length; i++) {
    var c = ca[i];
    while (c.charAt(0) === ' ') {
      c = c.substring(1);
    }
    try {
      if ((0, _includes2.default)(c, name)) {
        return c.substring(name.length, c.length);
      }
    } catch (error) {
      _logger2.default.warn({
        description: 'Cookie cannot be loaded.', cookieName: cookieName,
        error: error, func: 'getCookie', obj: 'cookiesUtil'
      });
      return '';
    }
  }
  return '';
}
1006873
protected String cookieValue(String name){
        Cookie cookie = cookie(name);
        return cookie != null ? cookie.getValue() : null;
    }
1039922
public static void setCookie(String name, String value, int maxAge, boolean httpOnly, HttpServletRequest request, HttpServletResponse response) {
		String domain = request.getServerName();
		// String domain = serverName;
		setCookie(name, value, maxAge, httpOnly, domain, response);
	}
49728
private Cookie createCookie(String str) throws UnsupportedEncodingException {
    if (LOG.isDebugEnabled()) {
      LOG.debug("Cookie name = " + AUTH_COOKIE + " value = " + str);
    }
    Cookie cookie = new Cookie(AUTH_COOKIE, str);

    cookie.setMaxAge(cookieMaxAge);
    if (cookieDomain != null) {
      cookie.setDomain(cookieDomain);
    }
    if (cookiePath != null) {
      cookie.setPath(cookiePath);
    }
    cookie.setSecure(isCookieSecure);
    return cookie;
  }
1122735
function(name) {
    var c = document.cookie.split(';');
    
    for (var i = 0, cookie; i < c.length; i++) {
      cookie = c[i].split('=');
      if (cookie[0].strip() === name)
        return cookie[1].strip();
    }
    
    return null;
  }
486498
public HttpResponse withCookie(String name, String value) {
        this.cookies.withEntry(name, value);
        return this;
    }
26128
function Cookie(name, value, attrs){
  if(!(this instanceof Cookie)) 
    return new Cookie(name, value, attrs);
  if(!name)  throw new TypeError('argument name is invalid');

  this.name   = name;
  this.value  = value;

  for (var key in attrs) {
    this[key] = attrs[key];
  }
  return this;
}
312869
public static NewCookie newDeletedCookie(String name) {
        /**
         * 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, DELETED_COOKIE_VALUE, "/", null, Cookie.DEFAULT_VERSION, null, 0, null, false, true);
    }
620415
public static String getCookieValue(Cookie[] cookies, String name) {

        for (int i = 0; (cookies != null) && (i < cookies.length); i++) {
            if (name.equalsIgnoreCase(cookies[i].getName())) {
                return cookies[i].getValue();
            }
        }
        return null;
    }
847670
@Override
    public boolean set(HttpCookie cookie, byte[] attribValue) {
        if (null == cookie || null == attribValue || 0 == attribValue.length) {
            return false;
        }

        // Start parsing the byte array here to set the expiry date
        // For example: 24-Jun-03 16:01:45 GMT is a valid attrib value
        // Using the HttpDateFormat class
        try {
            Date expiryDate = HttpDispatcher.getDateFormatter().parseTime(attribValue);
            long remainingTime = expiryDate.getTime() - HttpDispatcher.getApproxTime();
            if (-1 < remainingTime) {
                cookie.setMaxAge((int) (remainingTime / 1000L));
            } else {
                // PK62826 - old date will translate to a 0 max-age (immediate
                // expiration)
                cookie.setMaxAge(0);
            }
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Expires/max-age set to " + cookie.getMaxAge());
            }
            return true;
        } catch (ParseException e) {
            // No FFDC required
            if (TraceComponent.isAnyTracingEnabled() && tc.isDebugEnabled()) {
                Tr.debug(tc, "Error parsing expires date: " + GenericUtils.getEnglishString(attribValue));
            }
        }
        return false;
    }
1186447
function (name) {
      var hostname = document.location.hostname;
      if (hostname.indexOf('www.') === 0) {
        hostname = hostname.substring(4);
      }
      document.cookie = name + '=; domain=.' + hostname + '; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/';
      document.cookie = name + '=; expires=Thu, 01-Jan-1970 00:00:01 GMT; path=/';
    }
642146
public void setCookie(String name, String value, String path, long maxAge, boolean secure, boolean httpOnly) {
        Date now = new Date();
        Date expirationDate = new Date(now.getTime() + maxAge);
        setCookie(name, value, path, expirationDate, secure, httpOnly);
    }