Shares config with the language cookie as they serve a similar purpose
347491
def process_response(self, request, response):
        

        if hasattr(request, 'COUNTRY_CODE'):
            response.set_cookie(
                key=constants.COUNTRY_COOKIE_NAME,
                value=request.COUNTRY_CODE,
                max_age=settings.LANGUAGE_COOKIE_AGE,
                path=settings.LANGUAGE_COOKIE_PATH,
                domain=settings.LANGUAGE_COOKIE_DOMAIN
            )
        return response
816929
public static void setCookieData(
        String pcType,
        String username,
        String oufqn,
        HttpServletRequest request,
        HttpServletResponse response) {

        // set the PC type cookie only if security dialog is enabled
        if (OpenCms.getLoginManager().isEnableSecurity() && CmsStringUtil.isNotEmpty(pcType)) {
            Cookie pcTypeCookie = getCookie(request, COOKIE_PCTYPE);
            pcTypeCookie.setValue(pcType);
            setCookie(pcTypeCookie, false, request, response);
        }

        // only store user name and OU cookies on private PC types
        if (PCTYPE_PRIVATE.equals(pcType)) {
            // set the user name cookie
            Cookie userNameCookie = getCookie(request, COOKIE_USERNAME);
            userNameCookie.setValue(username);
            setCookie(userNameCookie, false, request, response);

            // set the organizational unit cookie
            Cookie ouFqnCookie = getCookie(request, COOKIE_OUFQN);
            ouFqnCookie.setValue(oufqn);
            setCookie(ouFqnCookie, false, request, response);
        } else if (OpenCms.getLoginManager().isEnableSecurity() && PCTYPE_PUBLIC.equals(pcType)) {
            // delete user name and organizational unit cookies
            Cookie userNameCookie = getCookie(request, COOKIE_USERNAME);
            setCookie(userNameCookie, true, request, response);
            Cookie ouFqnCookie = getCookie(request, COOKIE_OUFQN);
            setCookie(ouFqnCookie, true, request, response);

        }
    }
380340
def fmt_cookies(self, ck):
        
        cks = {}
        for c in ck.split(';'):
            a = c.split('=')
            if len(a) != 2:
                continue
            cks[a[0].replace(' ', '')] = a[1].replace(' ', '')
        self.cookies = cks
255769
def cookiestring(self, value):
        """""""
        c = Cookie.SimpleCookie(value)
        sc = [(i.key, i.value) for i in c.values()]
        self.cookies = dict(sc)
907499
def _build_cookie_jar(cls, session: AppSession):
        ''''''

        if not session.args.cookies:
            return

        if session.args.load_cookies or session.args.save_cookies:
            session.factory.set('CookieJar', BetterMozillaCookieJar)

            cookie_jar = session.factory.new('CookieJar')

            if session.args.load_cookies:
                cookie_jar.load(session.args.load_cookies, ignore_discard=True)
        else:
            cookie_jar = session.factory.new('CookieJar')

        policy = session.factory.new('CookiePolicy', cookie_jar=cookie_jar)

        cookie_jar.set_policy(policy)

        _logger.debug(__('Loaded cookies: {0}', list(cookie_jar)))

        cookie_jar_wrapper = session.factory.new(
            'CookieJarWrapper',
            cookie_jar,
            save_filename=session.args.save_cookies,
            keep_session_cookies=session.args.keep_session_cookies,
        )

        return cookie_jar_wrapper
318274
function fixedSaveCookies(res) {
    const cookies = res.headers['set-cookie'];

    if (cookies) {
        const fixedCookies = cookies.reduce(
            (cookies, cookie) => cookies.concat(cookie.split(/,(?!\s)/)),
            []
        );
        this.jar.setCookies(fixedCookies);
    }
}
255501
public void setLanguageCookie(String language, RouteContext routeContext) {
        String lang = getLanguageOrDefault(language);
        if (lang.equals(language)) {
            Cookie cookie = generateLanguageCookie(language);
            routeContext.getResponse().cookie(cookie);
        } else {
            throw new PippoRuntimeException("'{}' is not a registered language!", language);
        }
    }
1109047
def _load_cookie(self):
        """"""

        cookie = SimpleCookie(self._environ.get('HTTP_COOKIE'))
        vishnu_keys = [key for key in cookie.keys() if key == self._config.cookie_name]

        # no session was started yet
        if not vishnu_keys:
            return

        morsel = cookie[vishnu_keys[0]]
        morsel_value = morsel.value

        if self._config.encrypt_key:
            cipher = AESCipher(self._config.encrypt_key)
            morsel_value = cipher.decrypt(morsel_value)

        received_sid = Session.decode_sid(self._config.secret, morsel_value)
        if received_sid:
            self._sid = received_sid
        else:
            logging.warn("found cookie with invalid signature")
762508
def __addcookies(self):
        '''
        '''
        for cname, morsel in self.cookies.items():
            attrs = []
            value = morsel.get('version', '')
            if value != '' and value != '0':
                attrs.append('$Version=%s' % value)
            attrs.append('%s=%s' % (cname, morsel.coded_value))
            value = morsel.get('path')
            if value:
                attrs.append('$Path=%s' % value)
            value = morsel.get('domain')
            if value:
                attrs.append('$Domain=%s' % value)
            self.h.putheader('Cookie', "; ".join(attrs))
1282573
def set_cookie(cookies, key, value='', max_age=None, expires=None, path='/',
               domain=None, secure=False, httponly=False):
    ''''''
    cookies[key] = value
    if expires is not None:
        if isinstance(expires, datetime):
            now = (expires.now(expires.tzinfo) if expires.tzinfo else
                   expires.utcnow())
            delta = expires - now
            # Add one second so the date matches exactly (a fraction of
            # time gets lost between converting to a timedelta and
            # then the date string).
            delta = delta + timedelta(seconds=1)
            # Just set max_age - the max_age logic will set expires.
            expires = None
            max_age = max(0, delta.days * 86400 + delta.seconds)
        else:
            cookies[key]['expires'] = expires
    if max_age is not None:
        cookies[key]['max-age'] = max_age
        # IE requires expires, so set it if hasn't been already.
        if not expires:
            cookies[key]['expires'] = http_date(time.time() + max_age)
    if path is not None:
        cookies[key]['path'] = path
    if domain is not None:
        cookies[key]['domain'] = domain
    if secure:
        cookies[key]['secure'] = True
    if httponly:
        cookies[key]['httponly'] = True
226472
function _setCookieToken (cookies, cookieName, cookieDomain, token, payload) {
  const parts = token.split('.')
  const opts = { sameSite: 'lax', expires: new Date(payload.exp * 1000) }
  if (cookieDomain) {
    opts.domain = cookieDomain
    // to support subdomains we can't use the sameSite opt
    // we rely on our manual check of the origin
    delete opts.sameSite
  }
  cookies.set(cookieName, parts[0] + '.' + parts[1], { ...opts, httpOnly: false })
  cookies.set(cookieName + '_sign', parts[2], { ...opts, httpOnly: true })
}
684794
def dump_config(self):
        

        conf = copy_config(self.config, self.mutable_config_keys)
        conf['state'] = {
            'cookiejar_cookies': list(self.cookies.cookiejar),
        }
        return conf
83211
def save_config_value(request, response, key, value):
    """"""
    request.session[key] = value
    response.set_cookie(key, value, expires=one_year_from_now())
    return response
1107339
public function setLanguage($language = null)
    {
        if (is_null($language)) {
            if (($language = Yii::$app->request->getQueryParam('_lang')) !== null) {
                $this->language = $language;
                Yii::$app->response->cookies->add(new Cookie(['name' => '_lang', 'value' => $language]));
            } else if (($cookie = Yii::$app->request->cookies->get('_lang')) !== null) {
                $this->language = $cookie->value;
            } else if (($language = Yii::$app->request->getPreferredLanguage()) !== null) {
                $this->language = $language;
            }
        } else {
            $this->language = $language;
        }
    }
1009105
def store_current_alchemy_language(language)
      if language && language.id
        session[:alchemy_language_id] = language.id
        Language.current = language
      end
    end
229241
function() {
            var cookieString = "";

            utils.forEach(this._cookieStore, function (cookieValue, cookieKey) {
                cookieString += cookieKey;
                cookieString += '=';
                cookieString += cookieValue;
                cookieString += '; ';
            });

            return cookieString;

        }
638935
public function configure()
  {
    $tokenGenerator = new DefaultToken(94, DefaultToken::FORMAT_BASE64);

    $expire = strtotime(Remember::$expire, 0);
    $cookie = new PHPCookie("application_session", $expire, "/", "", true, true);

    Remember::$storage = new FileStorage(Remember::$tokensDir);
    Remember::$rememberMe = new Authenticator(Remember::$storage, $tokenGenerator, $cookie);
  }