Modify Response Cookie
767397
public function modifyResponseCookie($response, $name, $value = null, $expiration = 0)
    {
        $expiration = 1;
        if ($expiration == 0) {
            $expiration = 30; //Expire After 30 Days
        }
        if (is_numeric($expiration)) {
            $expiration = $expiration;
        }

        $modify = function (SetCookie $setCookie) {
            $value = $setCookie->getValue();

            // ... inspect current $value and determine if $value should
            // change or if it can stay the same. in all cases, a cookie
            // should be returned from this callback...

            return $setCookie
                ->withValue($value)
                ->withExpires($expiration)
            ;
        };

        $response = FigResponseCookies::modify($response, $name, $modify);

        return $response;
    }
317923
public static void setCookie(HttpServletResponse response, String name, String value, String path) {

		Cookie cookie = new Cookie(name, value);
		cookie.setSecure(false);
		cookie.setPath(path);
		cookie.setMaxAge(3600 * 24 * 30); // 30 days

		response.addCookie(cookie);
	}
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);
    }
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);
    }
168871
@Override
    public void addSSOCookiesToResponse(Subject subject, HttpServletRequest req, HttpServletResponse resp) {
        if (!allowToAddCookieToResponse(req))
            return;

        addJwtSsoCookiesToResponse(subject, req, resp);

        if (!JwtSSOTokenHelper.shouldAlsoIncludeLtpaCookie()) {
            return;
        }

        SingleSignonToken ssoToken = getDefaultSSOTokenFromSubject(subject);
        if (ssoToken == null) {
            return;
        }

        byte[] ssoTokenBytes = ssoToken.getBytes();
        if (ssoTokenBytes == null) {
            return;
        }

        ByteArray cookieBytes = new ByteArray(ssoTokenBytes);
        String cookieByteString = cookieByteStringCache.get(cookieBytes);
        if (cookieByteString == null) {
            cookieByteString = StringUtil.toString(Base64Coder.base64Encode(ssoTokenBytes));
            updateCookieCache(cookieBytes, cookieByteString);
        }

        Cookie ssoCookie = createCookie(req, cookieByteString);
        resp.addCookie(ssoCookie);
    }
394940
public void invalidateReferrerURLCookie(HttpServletRequest req, HttpServletResponse res, String cookieName) {
        invalidateCookie(req, res, cookieName, true);
    }
779647
public void setCookieData(HttpServletRequest request, HttpServletResponse response) {

        setCookieData(m_pcType, m_username, m_oufqn, request, response);
    }
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);
            }
        }
    }
1015050
protected static void setCookie(
        Cookie cookie,
        boolean delete,
        HttpServletRequest request,
        HttpServletResponse response) {

        if (request.getAttribute(PARAM_PREDEF_OUFQN) != null) {
            // prevent the use of cookies if using a direct ou login url
            return;
        }
        int maxAge = 0;
        if (!delete) {
            // set the expiration date of the cookie to six months from today
            GregorianCalendar cal = new GregorianCalendar();
            cal.add(Calendar.MONTH, 6);
            maxAge = (int)((cal.getTimeInMillis() - System.currentTimeMillis()) / 1000);
        }
        cookie.setMaxAge(maxAge);
        // set the path
        cookie.setPath(CmsStringUtil.joinPaths(OpenCms.getStaticExportManager().getVfsPrefix(), "/system/login"));
        // set the cookie
        response.addCookie(cookie);
    }
12888
function(response){
      if(window.localStorage){
        var save = JSON.stringify({token: response.session_token});
        localStorage.setItem('cloudmineTodoSession', save);
      }
      else {
        document.cookie = 'cloudmineTodoSession=' + response.session_token + '; expires=' + response.expires + '; path=/';
      }
      todo.get_items();
    }
663752
public static void resetCookieValue(HttpServletResponse response, String cookieName) {
        Cookie cookie = new Cookie(cookieName, null);
        cookie.setMaxAge(0);
        response.addCookie(cookie);
    }
1110402
function(res) {
  function addCookie(cookie) {
    try {
      cookieJar.setCookieSync(cookie, config.base_url);
    } catch (err) {
      throw err;
    }
  }

  if (Array.isArray(res.headers['set-cookie'])) {
    res.headers['set-cookie'].forEach(addCookie);
  } else {
    addCookie(res.headers['set-cookie']);
  }
}
681014
function serializeCookie(cookie) {
  return {
    path: cookie.path,
    name: cookie.key,
    value: cookie.value,
    domain: cookie.domain
  };
}
309544
protected void setCookies(HttpServletRequest request, HttpServletResponse response, String requestToken, String stateValue) {
        ReferrerURLCookieHandler referrerURLCookieHandler = WebAppSecurityCollaboratorImpl.getGlobalWebAppSecurityConfig().createReferrerURLCookieHandler();

        // Create cookie for request token
        Cookie requestTokenCookie = referrerURLCookieHandler.createCookie(TwitterConstants.COOKIE_NAME_REQUEST_TOKEN, requestToken, request);
        response.addCookie(requestTokenCookie);

        // Set original request URL in cookie
        String cookieName = ClientConstants.COOKIE_NAME_REQ_URL_PREFIX + stateValue.hashCode();
        Cookie c = referrerURLCookieHandler.createCookie(cookieName, webUtils.getRequestUrlWithEncodedQueryString(request), request);
        response.addCookie(c);

    }
284453
private function updateCookieHeader()
	{
		$strings = array();

		foreach ($this->cookies as $key => $value) {
			$strings[] = "{$key}={$value}";
		}

		$this->setHeader('cookie', implode('; ', $strings));
	}
1116007
function writeCookie (response, cookiePath) {
  try {
    debug('got response')
    var cookies = cookie.parse(response.headers['set-cookie'][0])
    debug('connect.sid', cookies['connect.sid'])
    fs.writeFileSync(cookiePath, JSON.stringify(cookies))
  } catch (e) {
    debug(e)
  }
}
1194866
public final static void addCookie(HttpServletResponse response, String name, String value, int maxAgeInSeconds) {
		addCookie(response, name, value, maxAgeInSeconds, "/", null);
	}