Stores the Session's ID, usually as a Cookie, to associate with future
        requests.

        :param session: the session that was just ``createSession`` created
199878
def on_start(self, session, session_context):
        
        session_id = session.session_id
        web_registry = session_context['web_registry']

        if self.is_session_id_cookie_enabled:
            web_registry.session_id = session_id
            logger.debug("Set SessionID cookie using id: " + str(session_id))

        else:
            msg = ("Session ID cookie is disabled.  No cookie has been set for "
                   "new session with id: " + str(session_id))
            logger.debug(msg)
43441
def _initialize_session():
    # type: () -> None
    
    sys_random = random.SystemRandom()
    _thread_local_storage.secret_key = b''.join(
        int2byte(sys_random.randint(0, 255))
        for _ in range(SECRET_KEY_BITS // 8))
402161
def _init_session(self, session):
        # type: (requests.Session) -> None
        
        _patch_redirect(session)

        # Change max_retries in current all installed adapters
        max_retries = self.config.retry_policy()
        for protocol in self._protocols:
            session.adapters[protocol].max_retries = max_retries
371126
def save_session(self, sid, session, namespace=None):
        
        return self.server.save_session(
            sid, session, namespace=namespace or self.namespace)
866989
private void saveSession(Session session) throws UnknownSessionException {
		if (session == null || session.getId() == null) {
			logger.error("session or session id is null");
			throw new UnknownSessionException("session or session id is null");
		}
		byte[] key;
		byte[] value;
		try {
			key = keySerializer.serialize(getRedisSessionKey(session.getId()));
			value = valueSerializer.serialize(session);
		} catch (SerializationException e) {
			logger.error("serialize session error. session id=" + session.getId());
			throw new UnknownSessionException(e);
		}
		if (expire == DEFAULT_EXPIRE) {
			this.redisManager.set(key, value, (int) (session.getTimeout() / MILLISECONDS_IN_A_SECOND));
			return;
		}
		if (expire != NO_EXPIRE && expire * MILLISECONDS_IN_A_SECOND < session.getTimeout()) {
			logger.warn("Redis session expire time: "
					+ (expire * MILLISECONDS_IN_A_SECOND)
					+ " is less than Session timeout: "
					+ session.getTimeout()
					+ " . It may cause some problems.");
		}
		this.redisManager.set(key, value, expire);
	}
788021
async def sessionstart(self):
        ""
        if not hasattr(self, 'session') or not self.session:
            self.session, setcookies = await call_api(self.container, 'session', 'start', {'cookies':self.rawcookie})
            for nc in setcookies:
                self.sent_cookies = [c for c in self.sent_cookies if c.key != nc.key]
                self.sent_cookies.append(nc)
900742
def start_session(self):
        
        self.session = self._session_start()
        result = yield gen.Task(self.session.fetch)
        self._set_session_cookie()
        if not self.session.get('ip_address'):
            self.session.ip_address = self.request.remote_ip
        self._last_values()
        raise gen.Return(result)
479381
def requests_session(self, *args, **kwargs):
        
        import requests
        auth1 = self.generate_auth()
        return requests.Session(*args, auth=auth1, **kwargs)
484799
def copy_session(session: requests.Session) -> requests.Session:
    """"""
    new = requests.Session()
    new.cookies = requests.utils.cookiejar_from_dict(requests.utils.dict_from_cookiejar(session.cookies))
    new.headers = session.headers.copy()
    return new
285346
def updateSession(self, request):
        
        # we actually need to copy some hardcoded constants from twisted :-(

        # Make sure we aren't creating a secure session on a non-secure page
        secure = request.isSecure()

        if not secure:
            cookieString = b"TWISTED_SESSION"
        else:
            cookieString = b"TWISTED_SECURE_SESSION"

        cookiename = b"_".join([cookieString] + request.sitepath)
        request.addCookie(cookiename, self.uid, path=b"/",
                          secure=secure)
980283
def ensure_session(engine_or_session):
    
    if isinstance(engine_or_session, Engine):
        engine_id = id(engine_or_session)
        if id(engine_id) in session_klass_cache: # pragma: no cover
            SessionClass = session_klass_cache[engine_id]
        else:  # pragma: no cover
            SessionClass = sessionmaker(bind=engine_or_session)
        ses = SessionClass()
        auto_close = True
        return ses, auto_close
    elif isinstance(engine_or_session, Session):
        ses = engine_or_session
        auto_close = False
        return ses, auto_close
526007
def save
      if data = session[Evercookie.hash_name_for_get]
        if data[:key] && cookies[data[:key]]
          session[Evercookie.hash_name_for_saved] =
              { data[:key] => cookies[data[:key]] }
        end
      end
      render nothing: true
    end
1077946
def session(self):
        
        if self._session is None:
            self._session = self.client.create_session()

        return self._session
970508
function makeSession(session) {
  return {
    authenticated: !!session.token,
    token: session.token,
    scope: session.scope,
    error: session.error,
    errorDescription: session.errorDescription
  };
}
1136641
async def save(self, request, response):
        """"""
        if isinstance(response, Response) and SESSION_KEY in request and not response.prepared:
            session = request[SESSION_KEY]
            if session.save(response.set_cookie):
                self.app.logger.debug('Session saved: %s', session)
654642
def _generate_session_id(self):
        """"""

        while True:
            rand = os.urandom(16)
            now = time.time()
            secret_key = self._config.secret_key
            session_id = hashlib.sha1(("%s%s%s%s" % (rand, now, utils.safestr(web.ctx.ip), secret_key)).encode("utf-8"))
            session_id = session_id.hexdigest()
            if session_id not in self.store:
                break
        return session_id
865097
def renew_session(self):
        
        if ((not 'user_uid' in self.cookieInterface.cookies) or self.cookieInterface.cookies['user_uid']!=self.session_uid) and (not self.expired):
            self.on_session_expired()

        if self.expired:
            self.session_uid = str(random.randint(1,999999999))
        
        self.cookieInterface.set_cookie('user_uid', self.session_uid, str(self.session_timeout_seconds))

        #here we renew the internal timeout timer
        if self.timeout_timer:
            self.timeout_timer.cancel()
        self.timeout_timer = threading.Timer(self.session_timeout_seconds, self.on_session_expired)
        self.expired = False
        self.timeout_timer.start()