Find a session from the Connect Session Store Note: Sessions are automatically created by the connect.session() middleware when the browser makes a HTTP request
348331
function(sessionId, socketId, cb) {
      return api.store.get().load(sessionId, function(err, session) {
        // Create a new session if we don't have this sessionId in memory
        // Note: in production you should be using Redis or another
        // persistent store so this should rarely happen
        if (!session) {
          session = strategy.create(sessionId);
          debug('created session for %s',sessionId);
        } else {
          debug('using existing session for %s',sessionId);
        }

        // Append methods to session object
        session.channel = channels(ss, session, socketId);
        session.setUserId = function(userId, cb) {
          if (!cb) {
            cb = function() {};
          }
          if (userId) {
            this.userId = userId;
            this._bindToSocket();
          } else if (this.userId) {  // if null (i.e. user has signed out)
            subscriptions.user.remove(this.userId, socketId);
            delete this.userId;
          }
          return this.save(cb);
        };

        // Bind username and any channel subscriptions to this socketID on each request
        session._bindToSocket = function() {
          if (session.userId) {
            subscriptions.user.add(session.userId, socketId);
          }
          if ((session.channels) && session.channels.length > 0) {
            session.channel._bindToSocket();
          }
          return this;
        };
        session.save = function(cb) {
          return sessionStore.set(sessionId, session, cb);
        };
        session._bindToSocket();
        return cb(session);
      });
    }
127552
public static Session create(SessionStore sessionStore, HttpRequest<?> request) {
        Session session = sessionStore.newSession();
        request.getAttributes().put(HttpSessionFilter.SESSION_ATTRIBUTE, session);
        return session;
    }
896360
def get(self, uri, params={}):
        '''
        '''
        return self._session.get(urljoin(Investigate.BASE_URL, uri),
            params=params, headers=self._auth_header, proxies=self.proxies
        )
386098
function createSession (callback) {
      var path, sessionCreate;

      _log(me.setting);
      path = me.setting.apiroot + '/session/create.json?apiKey=' + me.setting.apikey;
      _log(path);

      sessionCreate = http.request({
        port: me.setting.port,
        host: me.setting.host,
        method: 'POST',
        path: path
      });

      sessionCreate.on('response', function (response) {
        var data = '';

        _log('STATUS: ' + response.statusCode);
        _log('HEADERS: ' + JSON.stringify(response.headers));

        if (200 !== response.statusCode) {
          callback(response.statusCode);
          return;
        }

        response.on('data', function (chunk) {
          data += chunk;
        });

        response.on('end', function() {
          var sessionInfo = JSON.parse(data);
          _log('SID OK: ' + sessionInfo.sid);

          callback(response.statusCode, sessionInfo);
        });
      });

      sessionCreate.on('error', function(err) {
        console.error(err);
      });

      sessionCreate.end();
    }
117017
def session(self) -> SessionT:
        ''''''
        session = self._session_class()(
            connection_pool=self._connection_pool,
        )
        self.event_dispatcher.notify(self.ClientEvent.new_session, session)
        return session
963805
def http_session(self):
        
        if self._http_session is None:
            session = VerboseHTTPSession()
            session.headers.update(self.DEFAULT_HTTP_HEADERS)
            self._http_session = session
        return self._http_session
814990
def session(connection_string=None):
    """"""
    global _session_makers
    connection_string = connection_string or oz.settings["db"]

    if not connection_string in _session_makers:
        _session_makers[connection_string] = sessionmaker(bind=engine(connection_string=connection_string))

    return _session_makers[connection_string]()
754819
def _retrieve_session(self, session_key):
        
        session_id = session_key.session_id
        if (session_id is None):
            msg = ("Unable to resolve session ID from SessionKey [{0}]."
                   "Returning null to indicate a session could not be "
                   "found.".format(session_key))
            logger.debug(msg)
            return None

        session = self.session_store.read(session_id)

        if (session is None):
            # session ID was provided, meaning one is expected to be found,
            # but we couldn't find one:
            msg2 = "Could not find session with ID [{0}]".format(session_id)
            raise ValueError(msg2)

        return session
960545
def get_session(self, token_path=None):
        
        # TODO: remove token_path in future versions
        if token_path is not None:
            warnings.warn('"token_path" param will be removed in future versions.'
                          ' Use a TokenBackend instead.', DeprecationWarning)

        # gets a fresh token from the store
        token = self.token_backend.get_token()

        if token:
            client_id, _ = self.auth
            session = OAuth2Session(client_id=client_id, token=token)
        else:
            raise RuntimeError(
                'No auth token found. Authentication Flow needed')

        session.proxies = self.proxy

        if self.request_retries:
            retry = Retry(total=self.request_retries, read=self.request_retries,
                          connect=self.request_retries,
                          backoff_factor=RETRIES_BACKOFF_FACTOR,
                          status_forcelist=RETRIES_STATUS_LIST)
            adapter = HTTPAdapter(max_retries=retry)
            session.mount('http://', adapter)
            session.mount('https://', adapter)

        return session
138542
def get_session(user_agent):
    """"""

    client = requests.Session()
    client.headers.update({
        'Content-Type': 'application/json',
        'User-Agent': user_agent,
    })
    retry = Retry(connect=3, backoff_factor=3)
    adapter = HTTPAdapter(max_retries=retry)
    client.mount('https://', adapter)
    return client
329837
def get_new_session(self):
        """"""
        session = Session()
        session.headers = self.headers
        session.proxies = self._get_request_proxies()
        return session
939359
def _make_session():
        

        sess = requests.Session()
        sess.mount('http://', requests.adapters.HTTPAdapter(max_retries=False))
        sess.mount('https://', requests.adapters.HTTPAdapter(max_retries=False))

        return sess
806346
def session(self):
        
        self._session = requests.session()
        yield
        self._session.close()
        self._session = None
62512
def get(self, url):
        
        logger.debug('Making GET request to %s', url)
        return self.oauth_session.get(url)
878678
def do_get_session(self, session_key):
        
        session_id = session_key.session_id
        msg = ("do_get_session: Attempting to retrieve session with key " +
               str(session_id))
        logger.debug(msg)

        session = self._retrieve_session(session_key)

        if (session is not None):
            self.validate(session, session_key)

        return session
346507
def _get_web_session(self):
        
        if isinstance(self.backend, MobileWebAuth):
            return self.backend.session
        else:
            if self.backend.logged_on:
                sess = self.backend.get_web_session()

                if sess is None:
                    raise RuntimeError("Failed to get a web session. Try again in a few minutes")
                else:
                    return sess
            else:
                raise RuntimeError("SteamClient instance is not connected")
775496
def session(self):
        
        ret = self.session_class(
            client_id=self._client_id,
            client=self.client,
            auto_refresh_url=self.auto_refresh_url,
            auto_refresh_kwargs=self.auto_refresh_kwargs,
            scope=self.scope,
            state=self.state,
            blueprint=self,
            base_url=self.base_url,
            **self.kwargs
        )

        def token_updater(token):
            self.token = token

        ret.token_updater = token_updater
        return self.session_created(ret)