Add the passed cookie.

@param aCookie
The cookie to be added. May not be <code>null</code>.
559440
public static void addCookie (@Nonnull final Cookie aCookie)
  {
    ValueEnforcer.notNull (aCookie, "Cookie");

    final String sKey = aCookie.getName ();

    s_aRWLock.writeLocked ( () -> s_aCookies.put (sKey, aCookie));
  }
214219
protected void createDeviceFingerPrintCookie(final RequestContext context, final HttpServletRequest request, final String cookieValue) {
        val response = WebUtils.getHttpServletResponseFromExternalWebflowContext(context);
        cookieGenerator.addCookie(request, response, cookieValue);
    }
950329
@Override
    public void addCookie(Cookie cookie) {

        if (cookie == null) {
            throw new CmsIllegalArgumentException(Messages.get().container(Messages.ERR_ADD_COOKIE_0));
        }

        StringBuffer header = new StringBuffer(128);

        // name and value
        header.append(cookie.getName());
        header.append('=');
        header.append(cookie.getValue());

        // add version 1 / RFC 2109 specific information
        if (cookie.getVersion() == 1) {
            header.append("; Version=1");

            // comment
            if (cookie.getComment() != null) {
                header.append("; Comment=");
                header.append(cookie.getComment());
            }
        }

        // domain
        if (cookie.getDomain() != null) {
            header.append("; Domain=");
            header.append(cookie.getDomain());
        }

        // max-age / expires
        if (cookie.getMaxAge() >= 0) {
            if (cookie.getVersion() == 0) {
                // old Netscape format
                header.append("; Expires=");
                long time;
                if (cookie.getMaxAge() == 0) {
                    time = 10000L;
                } else {
                    time = System.currentTimeMillis() + (cookie.getMaxAge() * 1000L);
                }
                header.append(CmsDateUtil.getOldCookieDate(time));
            } else {
                // new RFC 2109 format
                header.append("; Max-Age=");
                header.append(cookie.getMaxAge());
            }
        }

        // path
        if (cookie.getPath() != null) {
            header.append("; Path=");
            header.append(cookie.getPath());
        }

        // secure
        if (cookie.getSecure()) {
            header.append("; Secure");
        }

        addHeader("Set-Cookie", header.toString());
    }
448339
@Override
    public void add(Widget widget) {
        if (widget instanceof HasJqmHeader) {
            setHeader((HasJqmHeader) widget);
            return;
        } else if (widget instanceof HasJqmFooter) {
            setFooter((HasJqmFooter) widget);
            return;
        } else if (widget instanceof JQMContent) {
            throw new RuntimeException("Do not add content widgets here, call createContent() instead");
        }
        getPrimaryContent().add(widget);

        // if page is already enhanced then we need to enhance the content manually
        // if (enhanced) triggerCreate();
    }
1115922
def add_cookie_header(self, request):
        
        _debug("add_cookie_header")
        self._cookies_lock.acquire()
        try:

            self._policy._now = self._now = int(time.time())

            cookies = self._cookies_for_request(request)

            attrs = self._cookie_attrs(cookies)
            if attrs:
                if not request.has_header("Cookie"):
                    request.add_unredirected_header(
                        "Cookie", "; ".join(attrs))

            # if necessary, advertise that we know RFC 2965
            if (self._policy.rfc2965 and not self._policy.hide_cookie2 and
                not request.has_header("Cookie2")):
                for cookie in cookies:
                    if cookie.version != 1:
                        request.add_unredirected_header("Cookie2", '$Version="1"')
                        break

        finally:
            self._cookies_lock.release()

        self.clear_expired_cookies()
64701
public function addCookie(CookieInterface $cookie)
    {

        // check if this cookie has already been set
        if ($this->hasCookie($name = $cookie->getName())) {
            // then check if we've already one cookie header available
            if (is_array($cookieValue = $this->getCookie($name))) {
                $cookieValue[] = $cookie;
            } else {
                $cookieValue = array($cookieValue, $cookie);
            }

            // add the cookie array
            $this->cookies[$name] = $cookieValue;

        } else {
            // when add it the first time, simply add it
            $this->cookies[$name] = $cookie;
        }
    }
298069
public static void setCookieValue(CmsJspActionElement jsp, String name, String value) {

        Cookie[] cookies = jsp.getRequest().getCookies();
        for (int i = 0; (cookies != null) && (i < cookies.length); i++) {
            if (name.equalsIgnoreCase(cookies[i].getName())) {
                cookies[i].setValue(value);
                return;
            }
        }
        Cookie cookie = new Cookie(name, value);
        jsp.getResponse().addCookie(cookie);
    }
1259108
public void addSetCookie(String name,
                             String value)
    {
        _header.addSetCookie(new Cookie(name,value));
    }
670694
public static boolean removeCookie(Cookie cookie, HttpServletResponse response) {
        if (Checker.isNotNull(cookie)) {
            cookie.setMaxAge(0);
            return addCookie(cookie, response);
        }
        return false;
    }
549902
public void add(SensorListener sensorListener) {
        if (!listeners.contains(sensorListener)) {
            listeners.add(sensorListener);
            if (!isEnabled()) {
                setEnabled(true);
            }
        }
    }
447520
protected synchronized void updateCookieCache(ByteArray cookieBytes, String cookieByteString) {
        if (cookieByteStringCache.size() > MAX_COOKIE_STRING_ENTRIES)
            cookieByteStringCache.clear();
        if (cookieByteString != null)
            cookieByteStringCache.put(cookieBytes, cookieByteString);
    }
784103
public static void addCookiesToResponse(List<Cookie> cookieList, HttpServletResponse resp) {
        Iterator<Cookie> iterator = cookieList.listIterator();
        while (iterator.hasNext()) {
            Cookie cookie = iterator.next();
            if (cookie != null) {
                resp.addCookie(cookie);
            }
        }
    }
457438
public void add(final URI uri, final HttpCookie cookie) {
        if(cookie.getMaxAge() == 0) {
            return;
        }

        if(cookie.getDomain() != null) {
            add(new DomainKey(cookie), cookie);
        }
        
        if(uri != null) {
            add(new UriKey(uri, cookie), cookie);
        }
    }
1177823
public URLConnectionRequestPropertiesBuilder withCookie(String cookieName, String cookieValue) {
        if (requestProperties.containsKey("Cookie")) {
            // there are existing cookies so just append the new cookie at the end
            final String cookies = requestProperties.get("Cookie");
            requestProperties.put("Cookie", cookies + COOKIES_SEPARATOR + buildCookie(cookieName, cookieValue));
        } else {
            // this is the first cookie to be added
            requestProperties.put("Cookie", buildCookie(cookieName, cookieValue));
        }
        return this;
    }
371617
public void sendCookie(String name, String value) {
        context.addCookie(Cookie.builder(name, value).build());
    }
891744
public static boolean addCookie(HttpServletResponse response, String name, String value, int expiry, String uri) {
        Cookie cookie = new Cookie(name, value);
        if (expiry > 0) {
            cookie.setMaxAge(expiry);
        }
        if (Checker.isNotEmpty(uri)) {
            cookie.setPath(uri);
        }
        return addCookie(cookie, response);
    }
482368
private void fillCookie(ArrayList<WebCookie> cookies, CharSegment rawCookie)
  {
    char []buf = rawCookie.buffer();
    int j = rawCookie.offset();
    int end = j + rawCookie.length();
    int version = 0;
    WebCookie cookie = null;

    while (j < end) {
      char ch = 0;

      CharBuffer cbName = _cbName;
      CharBuffer cbValue = _cbValue;

      cbName.clear();
      cbValue.clear();

      for (;
           j < end && ((ch = buf[j]) == ' ' || ch == ';' || ch ==',');
           j++) {
      }

      if (end <= j)
        break;

      boolean isSpecial = false;
      if (buf[j] == '$') {
        isSpecial = true;
        j++;
      }

      for (; j < end; j++) {
        ch = buf[j];
        if (ch < 128 && TOKEN[ch])
          cbName.append(ch);
        else
          break;
      }

      for (; j < end && (ch = buf[j]) == ' '; j++) {
      }

      if (end <= j)
        break;
      else if (ch == ';' || ch == ',') {
        try {
          cookie = new WebCookie(cbName.toString(), "");
          cookie.setVersion(version);
          _cookies.add(cookie);
          // some clients can send bogus cookies
        } catch (Exception e) {
          log.log(Level.FINE, e.toString(), e);
        }
        continue;
      }
      else if (ch != '=') {
        for (; j < end && (ch = buf[j]) != ';'; j++) {
        }
        continue;
      }

      j++;

      for (; j < end && (ch = buf[j]) == ' '; j++) {
      }

      if (ch == '"') {
        for (j++; j < end; j++) {
          ch = buf[j];
          if (ch == '"')
            break;
          cbValue.append(ch);
        }
        j++;
      }
      else {
        int head = j;
        int tail = j;
        
        for (; j < end; j++) {
          ch = buf[j];
          if (ch < 128 && VALUE[ch]) {
            cbValue.append(ch);
            tail = j + 1;
          }
          else if (ch == ' ') {
            cbValue.append(ch);
            // server/01ed
          }
          else {
            break;
          }
        }
        
        cbValue.length(tail - head);
      }

      if (! isSpecial) {
        if (cbName.length() == 0)
          log.warning("bad cookie: " + rawCookie);
        else {
          cookie = new WebCookie(toName(cbName), cbValue.toString());
          cookie.setVersion(version);
          _cookies.add(cookie);
        }
      }
      else if (cookie == null) {
        if (cbName.matchesIgnoreCase("Version"))
          version = cbValue.charAt(0) - '0';
      }
      else if (cbName.matchesIgnoreCase("Version"))
        cookie.setVersion(cbValue.charAt(0) - '0');
      else if (cbName.matchesIgnoreCase("Domain"))
        cookie.setDomain(cbValue.toString());
      else if (cbName.matchesIgnoreCase("Path"))
        cookie.setPath(cbValue.toString());
    }
  }