Returns an existing session. Used with repeat HTTP connections
belonging to the same JDBC Conenction / HSQL Session pair.
424092
public static Session getSession(int dbId, long sessionId) {

        Database db = (Database) databaseIDMap.get(dbId);

        return db == null ? null
                          : db.sessionManager.getSession(sessionId);
    }
50608
def get_sessionmaker(sqlalchemy_url, engine=None):
    
    if engine is None:
        engine = create_engine(sqlalchemy_url)
    return sessionmaker(bind=engine)
1311177
private Session getSession() throws NamingException {
		if (session == null) {
			synchronized (this) {
				try {
					session = (Session) lookupFromJndiName();
				} catch (final ClassCastException e) {
					// la déclaration d'une session mail dans un contexte tomcat par exemple
					// nécessite d'avoir les jars javamail et activation dans le répertoire lib
					// du serveur, mais si ces 2 jars sont aussi dans WEB-INF/lib de la webapp
					// pour une utilisation directe sans session mail alors on obtient ClassCastException
					// de javax.mail.Session en javax.mail.Session.
					// Pour pallier cela, on contourne ClassCastException en récupérant
					// les propriétés dans la session mail du serveur sans faire de cast
					// puis on recrée une session mail locale avec les jars de la webapp.
					session = Session.getInstance(getPropertiesFromSession(lookupFromJndiName()));
				}
			}
			fromAddress = InternetAddress.getLocalAddress(session);
		}
		return session;
	}
107166
def session(self):
        
        if self._session is None:
            self._session = urllib2.build_opener(urllib2.HTTPHandler)
        return self._session
813716
def get_requests_session():
    
    session = requests.sessions.Session()
    session.mount('http://', HTTPAdapter(pool_connections=25, pool_maxsize=25, pool_block=True))
    session.mount('https://', HTTPAdapter(pool_connections=25, pool_maxsize=25, pool_block=True))
    return session
909588
@Override
    public Object getSession(ServletRequest request, ServletResponse response, SessionAffinityContext affinityContext, boolean create) {

        /*
         * Check to see if the request provides a JSESSIONID cookie
         */
        String sessionID = _sam.getInUseSessionID(request, affinityContext);
        int sessionVersion = _sam.getInUseSessionVersion(request, affinityContext); // affinityContext.getRequestedSessionVersion();
        ISession session = null;

        /*
         * If the sessionID is not null, this may be a request with an existing
         * session.
         */
        if (sessionID != null) {
            session = (ISession) getSession(sessionID, sessionVersion, true, null);
            if (session == null && affinityContext.isRequestedSessionIDFromCookie() // perform allIds call and reset sac
                            && !affinityContext.isAllSessionIdsSetViaSet()){  //PM89885 add another check for isAllSessionIdsSetViaSet since we may have done a set in HttpSessionContextImpl.getIHttpSession
                List allSessionIds = _sam.getAllCookieValues(request);
                affinityContext.setAllSessionIds(allSessionIds);
            }
        }

        while ((session == null) && (_sam.setNextId(affinityContext))) {
            sessionID = _sam.getInUseSessionID(request, affinityContext);
            sessionVersion = _sam.getInUseSessionVersion(request, affinityContext); // affinityContext.getRequestedSessionVersion();
            session = (ISession) getSession(sessionID, sessionVersion, true, null);
        }

        /*
         * If the session is null, create a new one if required. The session manager
         * will check
         * to see if an alternate webmodule has a session created using
         * this session id. If not, the session object returned may have a different
         * session id from the one supplied.
         */
        if ((session == null) && create) {
            boolean reuseThisID = false;
            if (_store.getShouldReuseId() || affinityContext.isResponseIdSet() || affinityContext.isRequestedSessionIDFromSSL()) {
                reuseThisID = true;
            }
            session = createISession(sessionID, sessionVersion, reuseThisID);
        }

        return adaptAndSetCookie(request, response, affinityContext, session);

    }
989969
public HttpSession getSession(final HttpServletRequest servletRequest) {
        final HttpSession session;
        final String txId = getEmbeddedId(servletRequest, Prefix.TX);

        try {
            if (txId == null) {
                session = createSession(servletRequest);
            } else {
                session = getSessionFromTransaction(servletRequest, txId);
            }
        } catch (final SessionMissingException e) {
            LOGGER.warn("Transaction missing: {}", e.getMessage());
            return null;
        }

        return session;
    }
355926
def get_session(url):
    
    engine = create_engine(url)
    db_session = scoped_session(sessionmaker(engine))
    Base.metadata.create_all(engine)
    return db_session
757945
def get_instance(self, payload):
        
        return SessionInstance(self._version, payload, service_sid=self._solution['service_sid'], )
896800
def get_current_session(request, hproPk):
    """"""

    retour = {}

    base_key = 'plugit_' + str(hproPk) + '_'

    for key, value in request.session.iteritems():
        if key.startswith(base_key):
            retour[key[len(base_key):]] = value

    return retour
810255
def _get(self, *args, **kwargs):
        

        if 'timeout' not in kwargs:
            kwargs['timeout'] = self.timeout

        req = self.session.get(*args, **kwargs)
        return req
484338
private final Session getSession (final String targetName) throws NoSuchSessionException {

        final Session session = sessions.get(targetName);

        if (session != null) {
            return session;
        } else {
            throw new NoSuchSessionException("Session " + targetName + " not found!");
        }
    }
739407
def getSession(self):
        """"""
        if self.session is not None:
            return self.session

        # Get value of cookie header that was sent
        cookie_str = self.headers.get('Cookie')
        if cookie_str:
            cookie_obj = SimpleCookie(cookie_str)
            sid_morsel = cookie_obj.get(self.SESSION_COOKIE_NAME, None)
            if sid_morsel is not None:
                sid = sid_morsel.value
            else:
                sid = None
        else:
            sid = None

        # If a session id was not set, create a new one
        if sid is None:
            sid = randomString(16, '0123456789abcdef')
            session = None
        else:
            session = self.server.sessions.get(sid)

        # If no session exists for this session ID, create one
        if session is None:
            session = self.server.sessions[sid] = {}

        session['id'] = sid
        self.session = session
        return session
575876
def _session():
    '''
    
    '''

    config = __salt__['config.option']('zenoss')
    session = requests.session()
    session.auth = (config.get('username'), config.get('password'))
    session.verify = False
    session.headers.update({'Content-type': 'application/json; charset=utf-8'})
    return session
1212413
public IoSession getSession() {
        synchronized (lock) {
            if (sessions.isEmpty()) {
                return null;
            } else {
                final Object[] keys = sessions.keySet().toArray();
                for (int i = 0; i < sessions.size(); i++) { //
                    counter++;
                    final int pos = Math.abs(counter % sessions.size());
                    final IoSession session = sessions.get(keys[pos]);
                    if (isAvailable(session)) {
                        return session;
                    }
                }
                return null;
            }
        }
    }
493134
def get_session(self):
        
        response = _request_access_token(
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
            scopes=self.scopes,
        )

        oauth2credential = OAuth2Credential.make_from_response(
            response=response,
            grant_type=auth.CLIENT_CREDENTIALS_GRANT,
            client_id=self.client_id,
            client_secret=self.client_secret,
        )

        return Session(oauth2credential=oauth2credential)
1286438
function getSession (ctx) {
    let signedCookie = ctx.cookies.get(sessionKey, {signed: cookie.signed}) || ''
    signedCookie = signedCookie.split('.')

    return ctx.thunk()(function () {
      if (!storeAvailable) throw new Error('session store is not available')
      if (signedCookie[0]) return store.get(signedCookie[0])
    })(function (err, session) {
      if (err) throw err
      let sessionId
      let originalHash

      if (session) {
        sessionId = signedCookie[0]
        originalHash = signedCookie[1]
        if (hashSession(session, sessionId) !== originalHash) session = null
      }

      if (!session) {
        session = genSession()
        sessionId = genSid(sidSize)
        originalHash = hashSession(session, sessionId)
      }

      return {
        session: session,
        sessionId: sessionId,
        originalHash: originalHash,
        isNew: originalHash !== signedCookie[1]
      }
    })
  }