Gets cookie from request.

@param cookieName the cookie name
@param request    the request
@return the cookie from request
965993
public static Optional<Cookie> getCookieFromRequest(final String cookieName, final HttpServletRequest request) {
        val cookies = request.getCookies();
        if (cookies == null) {
            return Optional.empty();
        }
        return Arrays.stream(cookies).filter(c -> c.getName().equalsIgnoreCase(cookieName)).findFirst();
    }
122080
public String createStateCookie(HttpServletRequest request, HttpServletResponse response) {
        String stateValue = SocialUtil.generateRandom();
        String loginHint = socialWebUtils.getLoginHint(request);
        if (!request.getMethod().equalsIgnoreCase("GET") && loginHint != null) {
            stateValue = stateValue + loginHint;
        }
        if (tc.isDebugEnabled()) {
            Tr.debug(tc, "Setting cookie " + ClientConstants.COOKIE_NAME_STATE_KEY + " to " + stateValue);
        }
        Cookie stateCookie = referrerURLCookieHandler.createCookie(ClientConstants.COOKIE_NAME_STATE_KEY, stateValue, request);
        response.addCookie(stateCookie);
        return stateValue;
    }
1252782
public String getCookie(String name) {
		Cookie c = requestCookies.get().get(name);
		return c == null ? null : c.getValue();
	}
61028
@RequestMapping(value = "/userSession", method = RequestMethod.GET)
    @ResponseBody
    public JsonObject<?> session(HttpServletRequest request) {
        JsonObject<?> ret = JsonObject.create();
        String cookieValueUsername = CookieUtils.getCookieValue(request,
                UserWebConstant.CookieKey.USERNAME.getValue());
        String cookieValuePwd = CookieUtils.getCookieValue(request,
                UserWebConstant.CookieKey.PWDMD5.getValue());
        if (LoginValidator.isValid(cookieValueUsername, cookieValuePwd)) {
            LOG.info("Already logon with username=" + cookieValueUsername);
            ret.addData("id", UserWebConstant.USERMAP.get(cookieValueUsername).getUserId());
            ret.addData("name", cookieValueUsername);
            return ret;
        } else {
            ret.setStatus(GlobalResponseStatusMsg.NOT_LOGIN.getCode());
            ret.addStatusInfo(GlobalResponseStatusMsg.NOT_LOGIN.getMessage().getMessage());
        }

        return ret;
    }
1235720
@Nullable
    public Cookie getCookie(String name) {
        for (Cookie cookie : cookies) {
            if (cookie.name().equals(name)) {
                return cookie;
            }
        }
        return null;
    }
938207
def get_cookie_header(jar, request):
    
    r = MockRequest(request)
    jar.add_cookie_header(r)
    return r.get_new_headers().get('Cookie')
506970
public static Cookie findCookie(HttpServletRequest request, String name) {
        if (request != null) {
            Cookie[] cookies = request.getCookies();
            if (cookies != null && cookies.length > 0) {
                for (Cookie cookie : cookies) {
                    if (cookie.getName().equals(name)) {
                        return cookie;
                    }
                }
            }
        }
        return null;
    }
1006873
protected String cookieValue(String name){
        Cookie cookie = cookie(name);
        return cookie != null ? cookie.getValue() : null;
    }
1304187
public String getSessionId(HttpServletRequest request) {
		String sessionId = request.getParameter(ACCESSTOKEN);
		if(isBlank(sessionId)){
			sessionId = request.getHeader(ACCESSTOKEN);
		}
		if(isBlank(sessionId)){
			Cookie[] cookies = request.getCookies();
			if(cookies == null)return null;
			for (Cookie cookie : cookies) {
				if(sessionIdName.equals(cookie.getName())){
					sessionId = cookie.getValue();
					break;
				}
			}
		}
		return sessionId;
	}
413780
function getCookie(cname) {
            var name = cname + "=";
            var ca = doc.cookie.split(';'),
                i = 0,
                l = ca.length;
            for (; i < l; i++) {
                var c = ca[i];
                while (c.charAt(0) == ' ') {
                    c = c.substring(1);
                }if (c.indexOf(name) != -1) return unescape(c.substring(name.length, c.length));
            }
            return "";
        }
810736
public final static Cookie getCookie(HttpServletRequest httpServletRequest, String name) {
		final Map<String, Cookie> cookieMap = readCookieMap(httpServletRequest);
		return cookieMap == null ? null : cookieMap.get(name);
	}
905042
protected function getRememberMeKeyFromCookie(Request $request, $cookieName)
    {
        $ctp = new CookieTokenProvider();

        return $ctp->getKeyFromCookie($request, $cookieName);
    }
129526
public static String getCookieUsername(HttpServletRequest request) {
		String username = CookieUtil.getCookie("username", request);
		try {
			username = URLDecoder.decode(username, "UTF-8");
		}
		catch (UnsupportedEncodingException e) {
			throw new RuntimeException(e.getMessage(), e);
		}
		return username;
	}
1316109
public static Cookie getCookie(final Collection<Cookie> cookies, final String name) {
        if (cookies != null) {
            for (final Cookie cookie : cookies) {
                if (cookie != null && CommonHelper.areEquals(name, cookie.getName())) {
                    return cookie;
                }
            }
        }
        return null;
    }
398995
public Long getCookieToLong(String name) {
		String result = getCookie(name);
		return result != null ? Long.parseLong(result) : null;
	}
843937
public Cookie put(CharSequence name, Cookie cookie) {
        return cookies.put(name, cookie);
    }
828115
public String getTokenValue(String tokenName) {
		Cookie ck = tokenValues.get(tokenName);
		if (ck != null) {
			return ck.getValue();
		}
		return null;
	}