stick to one alternative until user deletes cookies or changes browser
772837
def bandit_sticky_choose(exp)
      name = "bandit_#{exp}".intern
      # choose url param with preference
      value = params[name].nil? ? cookies.signed[name] : params[name]
      # sticky choice may outlast a given alternative
      alternative = if Bandit.get_experiment(exp).alternatives.include?(value)
                      value
                    else
                      Bandit.get_experiment(exp).choose(value)
                    end
      # re-set cookie
      cookies.permanent.signed[name] = alternative
    end
124565
def set_cookie_close_window_response(self, account_cookie_value):
        """"""
        response = make_response(
            "<html><script>window.close();</script></html>", 200,
            {'Content-Type': "text/html"})
        response.set_cookie(self.account_cookie_name,
                            account_cookie_value)
        return response
172728
function check_cookies()
	{
		if (!$this->user['auth'] && isset($_COOKIE['eresus_login']))
		{
			if (!$this->login($_COOKIE['eresus_login'], $_COOKIE['eresus_key'], true, true))
			{
				$this->clear_login_cookies();
			}
		}
	}
610883
def logout(cookie=None):
    '''
    
    '''
    payload = '<aaaLogout cookie="{0}" inCookie="{0}"></aaaLogout>'.format(cookie)
    __utils__['http.query'](DETAILS['url'],
                            data=payload,
                            method='POST',
                            decode_type='plain',
                            decode=True,
                            verify_ssl=False,
                            raise_error=True,
                            headers=DETAILS['headers'])
    return
53198
def invalidate!
      self.active = false
      self.save!
      if controller
        cookies.delete(:user_session)
      end
      Authie.config.events.dispatch(:session_invalidated, self)
      true
    end
3338
function(user) {
        var promise;
        if (AV.User._currentUser !== user) {
          promise = AV.User.logOut();
        } else {
          promise = Promise.resolve();
        }
        return promise.then(function() {
          user._isCurrentUser = true;
          AV.User._currentUser = user;

          var json = user._toFullJSON();
          json._id = user.id;
          json._sessionToken = user._sessionToken;
          return AV.localStorage
            .setItemAsync(
              AV._getAVPath(AV.User._CURRENT_USER_KEY),
              JSON.stringify(json)
            )
            .then(function() {
              AV.User._currentUserMatchesDisk = true;
              return AV._refreshSubscriptionId();
            });
        });
      }
176637
def signout(self, redirect_url = "/"):
        
        self.clear_cookie(self._USER_NAME)
        if redirect_url: self.redirect(redirect_url)
598735
function clear() {
  var cookies = isBrowser && document.cookie.split(';');

  if (!cookies.length) {
    return;
  }

  for (var i = 0, l = cookies.length; i < l; i++) {
    var item = cookies[i];
    var key = item.split('=')[0];

    cookie.remove(key);
  }
}
40331
function isOptOut() {
  // Check cookie first
  let optOutState = getCookie();

  // No cookie info, check localStorage
  if (optOutState === null) {
    optOutState = getLocalStorage();
  }

  // No localStorage, we get default value
  if (optOutState === null || typeof optOutState === 'undefined') {
    optOutState = false;
  }

  // Set global for the environment
  window[disableStr] = optOutState;

  return optOutState;
}
655502
def set_cookie(self, cookie=None):
        """"""
        if cookie:
            self._cookie = cookie.encode()
        else:
            self._cookie = None
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;
}
1071001
function removeOauthResultFromCurrentUrl() {
  if (window.history && window.history.replaceState) {
    var url = window.location.href;
    var hashIndex = url.indexOf('#');
    window.history.replaceState({},
      document.title, url.substring(0, hashIndex));
  } else {
    window.location.hash = '';
  }
}
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]);
}
516588
function login(user, callback) {
      /* jshint validthis:true */
      var cb = callback || angular.noop;
      var deferred = $q.defer();
      $cookies.customerId = user.customerId;

      $http.post('/auth/local', {
        customerId: user.customerId,
        name: user.name,
        password: user.password
      }).success(function (data) {
        $cookieStore.put('token', data.token);
        $cookieStore.remove('customerID');
        currentUser = User.get();
        deferred.resolve(data);
        return cb();
      }).error(function (err) {
        this.logout();
        deferred.reject(err);
        return cb(err);
      }.bind(this));

      return deferred.promise;
    }
1173936
def after_request(response)
      unless @authenticating
        if captcha_required(response) # rubocop:disable Style/GuardClause
          raise Jiralicious::CaptchaRequired, "Captacha is required. Try logging into Jira via the web interface"
        elsif cookie_invalid(response)
          # Can usually be fixed by logging in again
          clear_session
          raise Jiralicious::CookieExpired
        end
      end
      @authenticating = false
    end
235813
def update_cookies(self, cookies: Optional[LooseCookies]) -> None:
        """"""
        if not cookies:
            return

        c = SimpleCookie()
        if hdrs.COOKIE in self.headers:
            c.load(self.headers.get(hdrs.COOKIE, ''))
            del self.headers[hdrs.COOKIE]

        if isinstance(cookies, Mapping):
            iter_cookies = cookies.items()
        else:
            iter_cookies = cookies  # type: ignore
        for name, value in iter_cookies:
            if isinstance(value, Morsel):
                # Preserve coded_value
                mrsl_val = value.get(value.key, Morsel())
                mrsl_val.set(value.key, value.value, value.coded_value)  # type: ignore  # noqa
                c[name] = mrsl_val
            else:
                c[name] = value  # type: ignore

        self.headers[hdrs.COOKIE] = c.output(header='', sep=';').strip()
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 })
}