/*
create the core session manager
194547
public IGenericSessionManager createCoreSessionManager(boolean removeAttrOnInvalidate) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CREATE_CORE_SESSION_MANAGER], "appName = " + _sap.getAppName());
        }

        String _sessionManagerID = _sap.getAppName();
        /*
         * create the session manager
         */
        IGenericSessionManager _sessionManager = new SessionManager(_sessionManagerID);
        /*
         * Get a handle to the SessionManagerCustomizer and
         * customize the session manager.
         */
        ISessionManagerCustomizer sessionMgrCustomizer = _sessionManager.getSessionManagerCustomizer();

        // servlet context
        sessionMgrCustomizer.setServletContext(_sap.getServletContext());

        // id generator
        sessionMgrCustomizer.setIDGenerator(new IDGeneratorImpl(SessionManagerConfig.getSessionIDLength()));

        // cookie config
        SessionCookieConfigImpl sessionCookieConfig = _sap.getSessionCookieConfig();
        if (sessionCookieConfig != null) {
            _smc.updateCookieInfo(sessionCookieConfig);
        }

        // tracking mode
        EnumSet<SessionTrackingMode> trackingMode = _sap.getSessionTrackingModes();
        if (trackingMode != null) {
            _smc.updateTrackingMode(trackingMode);
        }

        // session timeout
        long sessionTimeout = _sap.getSessionTimeout();
        if (sessionTimeout == 0) { // no value from web.xml
            sessionTimeout = _smc.getSessionInvalidationTime();
        }
        sessionTimeout = checkMinimumInvalidation(sessionTimeout);
        sessionMgrCustomizer.setSessionTimeout((int) sessionTimeout);

        // protocol adapter
        IProtocolAdapter adapter = new WasHttpSessionAdapter(this, _sap.getServletContext());
        sessionMgrCustomizer.setAdapter(adapter);

        // session listeners
        // only call new constructor if we actually have SessionidListeners
        if( mHttpSessionIdListeners == null ) {
            wasHttpSessionObserver = new WasHttpSessionObserver(mHttpSessionListeners, adapter);
        } else {
            wasHttpSessionObserver = new WasHttpSessionObserver(mHttpSessionListeners, mHttpSessionIdListeners, adapter);
        }
       
        sessionMgrCustomizer.registerSessionObserver(wasHttpSessionObserver);

        // session attribute listeners
        sessionMgrCustomizer.registerSessionStateObserver(new HttpSessionAttributeObserver(mHttpSessionAttributeListeners, adapter));

        // store
        IStore _store = null;
        if(!removeAttrOnInvalidate){
               _store = createStore(_smc, _sessionManagerID, _sap.getServletContext(), false);
        }
        else{
            _store = createStore(_smc, _sessionManagerID, _sap.getServletContext(), false , removeAttrOnInvalidate);
        }
        _store.setDistributable(_sap.getDistributableWebApp());
        sessionMgrCustomizer.registerStore(_store);

        // invalidator
        _invalidator = createInvalidator();
        int reaperInterval = getReaperInterval(sessionTimeout);
        _invalidator.start(_store, reaperInterval);

        // storer - handles manual write, eos, and time based differences
        _storer = createStorer(_smc, _store);
        sessionMgrCustomizer.registerStorer(_storer);

        // affinity manager
        ISessionAffinityManager isam = createSessionAffinityManager(_smc, this, _store);
        sessionMgrCustomizer.registerAffinityManager(isam);
        _sam = isam;

        // zOS servant affinity
        ISessionObserver servantAffinityManager = getServantAffinityManager(_smc, adapter, _sap.getAppName());
        if (servantAffinityManager != null) {
            sessionMgrCustomizer.registerSessionObserver(servantAffinityManager);
        }

        SessionManagerRegistry.getSessionManagerRegistry().registerSessionManager(_sessionManagerID, _sessionManager);

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CREATE_CORE_SESSION_MANAGER], "_sessionManager =" + _sessionManager);
        }
        return _sessionManager;
    }
201615
@Override
    public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
        connectionLock.readLock().lock();
        try {
            ManagedSession managedSession = new ManagedSession(
                    getConnection().createSession(transacted, acknowledgeMode),
                    transacted,
                    acknowledgeMode,
                    connectionDefinition.isJeeMode(),
                    this);
            sessions.add(managedSession);
            return managedSession;
        } finally {
            connectionLock.readLock().unlock();
        }
    }
333309
protected SessionFactory createSessionFactory( ConnectionProvider connectionProvider, RetryLogic retryLogic,
            Config config )
    {
        return new SessionFactoryImpl( connectionProvider, retryLogic, config );
    }
142663
def create_exposed_session(self, session, key=None, context=None):
        
        # shiro ignores key and context parameters
        return DelegatingSession(self, SessionKey(session.session_id))
472299
def createManager(self, services, yadis_url=None):
        
        key = self.getSessionKey()
        if self.getManager():
            raise KeyError('There is already a %r manager for %r' %
                           (key, self.url))

        if not services:
            return None

        manager = YadisServiceManager(self.url, yadis_url, services, key)
        manager.store(self.session)
        return manager
607442
public SessionLockManager getSessionLockManager(String sessionId, SessionDataManager transientManager)
   {
      CacheableSessionLockManager sessionManager = new CacheableSessionLockManager(sessionId, this, transientManager);
      sessionLockManagers.put(sessionId, sessionManager);
      return sessionManager;
   }
228688
function BrowserStackSessionManager(options) {

  log.debug('[chimp][browserstack-session-manager] options are', options);

  var host = options.host.replace(/hub\.|hub-cloud\./, 'api.');
  var browserStackBaseUrl = 'https://' + options.user + ':' + options.key + '@' + host;
  options.browserStackUrl = browserStackBaseUrl;

  this.options = options;

  this.maxRetries = 30;
  this.retryDelay = 3000;
  this.retry = 0;

  // this will be set by the remote and multiremote methods from
  // desiredCapabilities
  this.buildName = null;

  log.debug('[chimp][browserstack-session-manager] created a new SessionManager', options);

}
1342466
@Override
    protected TransportResolver createResolver(JingleSession session) {
        BridgedResolver bridgedResolver = new BridgedResolver(this.xmppConnection);
        return bridgedResolver;
    }
402933
function SessionManager(config, encrypter) {
    /**
     * The configuration object
     *
     * @var Object
     * @protected
     */
    this.__config = config;

    /**
     * The registered custom driver creators.
     *
     * @var Object
     * @protected
     */
    this.__customCreators = {};

    /**
     * The encrypter instance.
     * An encrypter implements encrypt and decrypt methods.
     *
     * @var Object
     * @protected
     */
    this.__encrypter = encrypter;

    /**
     * The session database model instance
     *
     * @var Object
     * @protected
     */
    this.__sessionModel;

    /**
     * The memory session handler storage
     * @type {null}
     * @protected
     */
    this.__memorySession = Object.create(null);
}
945940
@Override
    public Session newSession(String id) {
        long created = System.currentTimeMillis();
        Session session = sessionCache.newSession(id, created, (defaultMaxIdleSecs > 0 ? defaultMaxIdleSecs * 1000L : -1));
        try {
            sessionCache.put(id, session);
            sessionsCreatedStats.increment();

            for (SessionListener listener : sessionListeners) {
                listener.sessionCreated(session);
            }

            return session;
        } catch (Exception e) {
            log.warn("Failed to create a new session", e);
            return null;
        }
    }
1277733
def _build_phantomjs_coprocessor(cls, session: AppSession, proxy_port: int):
        ''''''
        page_settings = {}
        default_headers = NameValueRecord()

        for header_string in session.args.header:
            default_headers.parse(header_string)

        # Since we can only pass a one-to-one mapping to PhantomJS,
        # we put these last since NameValueRecord.items() will use only the
        # first value added for each key.
        default_headers.add('Accept-Language', '*')

        if not session.args.http_compression:
            default_headers.add('Accept-Encoding', 'identity')

        default_headers = dict(default_headers.items())

        if session.args.read_timeout:
            page_settings['resourceTimeout'] = session.args.read_timeout * 1000

        page_settings['userAgent'] = session.args.user_agent \
                                     or session.default_user_agent

        # Test early for executable
        wpull.driver.phantomjs.get_version(session.args.phantomjs_exe)

        phantomjs_params = PhantomJSParams(
            wait_time=session.args.phantomjs_wait,
            num_scrolls=session.args.phantomjs_scroll,
            smart_scroll=session.args.phantomjs_smart_scroll,
            snapshot=session.args.phantomjs_snapshot,
            custom_headers=default_headers,
            page_settings=page_settings,
            load_time=session.args.phantomjs_max_time,
        )

        extra_args = [
            '--proxy',
            '{}:{}'.format(session.args.proxy_server_address, proxy_port),
            '--ignore-ssl-errors=true'
        ]

        phantomjs_driver_factory = functools.partial(
            session.factory.class_map['PhantomJSDriver'],
            exe_path=session.args.phantomjs_exe,
            extra_args=extra_args,
        )

        phantomjs_coprocessor = session.factory.new(
            'PhantomJSCoprocessor',
            phantomjs_driver_factory,
            session.factory['ProcessingRule'],
            phantomjs_params,
            root_path=session.args.directory_prefix,
            warc_recorder=session.factory.get('WARCRecorder'),
        )

        return phantomjs_coprocessor
1360099
def create_exposed_session(self, session, key=None, context=None):
        
        if key:
            return WebDelegatingSession(self, key)

        web_registry = context['web_registry']
        session_key = WebSessionKey(session.session_id,
                                    web_registry=web_registry)

        return WebDelegatingSession(self, session_key)
106318
@Override
    public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException {
        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession", new Object[] { transacted, acknowledgeMode });

        JmsSessionImpl jmsSession = null;

        // throw an exception if the connection is closed.
        checkClosed();

        // mark that the client id cannot be changed.
        fixClientID();

        // enforce consistency on transacted flag and acknowledge mode.
        if (transacted) {
            acknowledgeMode = Session.SESSION_TRANSACTED;
        }
        if (!transacted && isManaged) {
            if (acknowledgeMode == Session.CLIENT_ACKNOWLEDGE) {
                throw (JMSException) JmsErrorUtils.newThrowable(JMSException.class,
                                                                "INVALID_ACKNOWLEDGE_MODE_CWSIA0514",
                                                                new Object[] { acknowledgeMode },
                                                                tc
                                );
            }
            // if the ackmode is dups_ok then set it to dups_ok, for all the other combination 
            // set it to auto_ack
            if (acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE)
                acknowledgeMode = Session.DUPS_OK_ACKNOWLEDGE;
            else
                acknowledgeMode = Session.AUTO_ACKNOWLEDGE;
        }

        // create the jca session.
        boolean internallyTransacted = (transacted
                                        || acknowledgeMode == Session.CLIENT_ACKNOWLEDGE
                                        || acknowledgeMode == Session.DUPS_OK_ACKNOWLEDGE);
        JmsJcaSession jcaSession = createJcaSession(internallyTransacted);

        // Lock here so that another thread using the same connection doesn't reset the 
        // coreConnection to something else as as we are instantiating the Session 
        synchronized (this)
        {
            try
            {
                // We potentially have a new coreConnection becuase the creation of the JcaSession
                // detected that the coreConnection is now invalid and so a new managedConnection
                // and coreConnection was created. So reset the coreConnection for this JmsConnection
                // to the new one or we just set the old one again.
                coreConnection = jcaSession.getSICoreConnection();
            } catch (IllegalStateException e)
            {
                FFDCFilter.processException(e, "com.ibm.ws.sib.api.jms.impl.JmsConnectionImpl", "createSession#2", this);

                if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                    SibTr.exit(this, tc, "createSession", jmsSession);

                throw (JMSException) JmsErrorUtils.newThrowable(
                                                                JMSException.class,
                                                                "JCA_CREATE_SESS_CWSIA0024",
                                                                null,
                                                                e,
                                                                "JmsConnectionImpl.createSession#2",
                                                                this,
                                                                tc);
            }
            // instantiate the jms session, and add it to this connection's session list.
            jmsSession = instantiateSession(transacted, acknowledgeMode, coreConnection, jcaSession);
        }
        synchronized (stateLock) {
            sessions.add(jmsSession);
            // d353701 - output a warning message if there are 'lots' of sessions active.
            if (sessions.size() % SESSION_WARNING_THRESHOLD == 0) {
                // We wish to tell the user which line of their application created the session,
                // so we must obtain a line of stack trace from their application.
                String errorLocation = JmsErrorUtils.getFirstApplicationStackString();
                SibTr.warning(tc, "MANY_SESSIONS_WARNING_CWSIA0027", new Object[] { "" + sessions.size(), errorLocation });
            }
        }

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.exit(this, tc, "createSession", jmsSession);
        return jmsSession;
    }
206934
@Override
  public Session create(CassandraStorage cassandra) {
    Closer closer = Closer.create();
    try {
      Cluster cluster = closer.register(buildCluster(cassandra));
      cluster.register(new QueryLogger.Builder().build());
      Session session;
      String keyspace = cassandra.keyspace();
      if (cassandra.ensureSchema()) {
        session = closer.register(cluster.connect());
        Schema.ensureExists(keyspace, cassandra.searchEnabled(), session);
        session.execute("USE " + keyspace);
      } else {
        LOG.debug("Skipping schema check on keyspace {} as ensureSchema was false", keyspace);
        session = cluster.connect(keyspace);
      }

      initializeUDTs(session);

      return session;
    } catch (RuntimeException e) {
      try {
        closer.close();
      } catch (IOException ignored) {
      }
      throw e;
    }
  }
689137
public function createSession()
    {
        $obj = new stdClass();

        $obj->Timestamp = $this->getTimeStamp();
        $obj->Username = $this->getUsername();
        $obj->PinCode = $this->getPinCode();
        $obj->UserAgent = $this->getUserAgent();

        // Generate Checksum
        $obj->Checksum = $this->generateChecksum($obj);

        // PinCode only used for the Checksum
        unset($obj->PinCode);

        // Create the session and get the response
        $response = $this->client->CreateSession($obj);
        $result = $response->CreateSessionResult;

        // Verify response data by making a new Checksum
        $res = new stdClass();
        // Must be in specific order for checksum -----
        $res->Timestamp = $result->Timestamp;
        $res->SessionID = $result->SessionID;
        $res->PinCode = $this->getPinCode();
        $res->Success = $result->Success;
        $res->Description = $result->Description;
        // --------------------------------------------
        $checkSum = $this->generateChecksum($res);

        // Compare Checksums
        if ($result->Checksum != $checkSum)
            throw new Exception("Data could not be verified");

        // Assign Session
        $this->_session = $result;

        $this->createCookie(true);
        $this->createPHPSession(true);

        // Return Respsonse
        return (array) $response;
    }
22489
@Override
    public Session createSession() throws JMSException {

        if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
            SibTr.entry(this, tc, "createSession");

        Session session = null;
        try {
            session = createSession(false, Session.AUTO_ACKNOWLEDGE);
        } finally {
            if (TraceComponent.isAnyTracingEnabled() && tc.isEntryEnabled())
                SibTr.exit(this, tc, "createSession");
        }

        return session;
    }
950300
function SessionStorage_construct(config) {
        this.timeouts = {};
        this.config = core.extend(
            {
                cookieKey: 'session_id',
                time: 60 * 20 * 1000, // 20 min default session time
                storage: null,
                key_prefix: 'SESSION_ID_KEY_'
            },
            config
        );

        if (!this.config.storage) {
            this.config.storage = cache;
        } else if (Type.isString(this.config.storage)) {
            this.config.storage = di.load(this.config.storage);
        }

        if(!(this.config.storage instanceof StorageInterface)) {
            throw new error.HttpError(500, this.config, 'Session storage must be instance of interface/storage');
        }
    }