build a new session
@param create create session or not
@return session
507988
private HttpSession2 buildSession(boolean create) {
        if (create) {
            session = buildSession(sessionManager.getSessionIdGenerator().generate(request), true);
            log.debug("Build new session[{}].", session.getId());
            return session;
        } else {
            return null;
        }
    }
267991
@Override
    public ISession createSession(String id, boolean newId) {
        // assert (id!=null);
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINER)) {
            StringBuffer sb = new StringBuffer("{").append(id).append(",").append(newId).append("} ").append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[CREATE_SESSION], sb.toString());
        }
        MemorySession sess = null;

        // need to test on a different language
        // try creating a temporary logger with the old resource bundle, and then
        // changing the environment to French or something
        if (inProcessOfStopping) {
            throwException("SessionContext.createWhenStop");
        }
        if ((!_smc.getEnableOverflow()) && (_sessions.size() >= _smc.getInMemorySize())) {
            // if we know we're in an overflow situation, don't bother
            // creating a new session
            if (_sessionStatistics != null) {
                _sessionStatistics.incNoRoomForNewSession();
            }
            sess = overflowSession;
        }
        // We expect the second part of check below - _sessions.get(id) == null --
        // to pass unless
        // the id generator generates a dup. This really should never happen.
        // The synchronization in SessionManager.createISession will prevent
        // multiple threads
        // with the same incoming id from both getting into this code. We're no
        // longer using
        // the newId parm...it could be removed, but its now part of the IStore
        // interface.
        if ((sess == null) && (_sessions.get(id) == null)) {
            if(!_removeAttrOnInvalidate)
                sess = new MemorySession(this, id, _storeCallback);
            else{
                if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
                    LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[CREATE_SESSION], "Create MemorySession with _removeAttrOnInvalidate -->" + _removeAttrOnInvalidate );
                }
                sess = new MemorySession(this, id, _storeCallback, _removeAttrOnInvalidate);
            }
            sess.setUserName(ANONYMOUS_USER);
            // since this was a newly created session, we need to update the
            // lastAccessTime to the create time
            sess.updateLastAccessTime(sess.getCreationTime());
            try {
                _sessions.put(id, sess);
            } catch (TooManySessionsException tmse) {
                // could catch this exception if multiple threads get past the
                // first overflow check and then attempt to do the sessions.put
                sess = overflowSession;
            }
        }

        // Returns a new session if everything is good
        // Returns an overflowSession is overflow is not allowed and we've already
        // hit the maximum number in memory
        // Returns null if there was an existing session with this key - should
        // never happen

        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[CREATE_SESSION], sess);
        }
        return sess;
    }
114607
function createSession(config, cb) {
  cb = utils.callOnce(cb)

  DEBUG("create", utils.JS(config))

  var channel = channels.createChannel(config.url)
  var session = new Session(channel, config, cb)
}
368866
def get_session(self, create=True):
        
        msg = ("{0} attempting to get session; create = {1}; \'session is None\' ="
               "{2} ; \'session has id\' = {3}".
               format(self.__class__.__name__, create, (self.session is None), str(
                      self.session is not None and bool(self.session.session_id))))
        logger.debug(msg)

        if self.session and not create:  # touching a new session is redundant
            self.session.touch()  # this is used to reset the idle timer (new to yosai)
            return self.session

        if (not self.session and create):
            if (not self.is_session_creation_enabled()):
                msg = ("Session creation is disabled for the current subject. "
                       "This exception indicates that there is "
                       "either a programming error (using a session when "
                       "it should never be used) or that Yosai's "
                       "configuration needs to be adjusted to allow "
                       "Sessions to be created for the current Subject.")
                raise ValueError(msg)

            msg = ("Starting session for host ", str(self.host))
            logger.debug(msg)

            session_context = self.create_session_context()
            session = self.security_manager.start(session_context)
            session.stop_session_callback = self.session_stopped
            self.session = session

        return self.session
684067
public void sessionCreated(final HttpSessionEvent event) {
		counter++;
		final HttpSession session = event.getSession();
		final String id = session.getId();
		SESSIONS.put(id, session);
	}
326433
private Session getOrCreateSession(@NotNull String keyspace) {
        Timer timer = getMetricsFactory().getTimer("cassandraClient.getOrCreateSession");

        Session currentSession = sessionsByKeyspace.computeIfAbsent(keyspace, key -> {
            LOGGER.debug("Create session for [{}]", keyspace);

            Session session = getCluster().connect(key);
            session.init();

            return session;
        });

        timer.stop();

        return currentSession;
    }
119866
protected SessionFactory createSessionFactory() {
        // Set up a service registry.
        StandardServiceRegistryBuilder b = new StandardServiceRegistryBuilder();

        // configures settings from hibernate.cfg.xml
        ServiceRegistry registry = b.configure().build();

        // Build the session factory.
        return new MetadataSources(registry)
                .buildMetadata()
                .buildSessionFactory();
    }
724622
public function createSession() {
        if (!isset($_SESSION)) {
           if (PHP_SAPI === 'cli') {
              $_SESSION = array();
           } elseif (!headers_sent()) {
              if (!session_start()) {
                 throw new SessionException('session_start failed.');
              }
           } else {
              throw new SessionException('Session started after headers sent.');
           }
        }
        $mmfSession = new Session($_SESSION);
        return $mmfSession;
    }
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;
    }
421741
@Override
    public ExtWebDriver createNewSession(Map<String, String> options, WebDriver wd) {
        DefaultExtWebDriver selenium = new DefaultExtWebDriver();
        selenium.setWrappedDriver(wd);

        // Get client properties file
        ClientProperties properties = new ClientProperties(options);

        // Set client properties (specific to our factory/implementation)
        selenium.setClientProperties(properties);

        // Set timeout value
        selenium.setMaxRequestTimeout(properties.getMaxRequestTimeoutString());

        // Highlighting
                selenium.setHighlightColors(properties.getHighlightColorMap());
                selenium.setIsHighlight(properties.isHighlight());

        return selenium;
    }
132466
public WebDriver build() {
    if (options.isEmpty() && additionalCapabilities.isEmpty()) {
      throw new SessionNotCreatedException("Refusing to create session without any capabilities");
    }

    Plan plan = getPlan();

    CommandExecutor executor;
    if (plan.isUsingDriverService()) {
      AtomicReference<DriverService> serviceRef = new AtomicReference<>();

      executor = new SpecCompliantExecutor(
          () -> {
            if (serviceRef.get() != null && serviceRef.get().isRunning()) {
              throw new SessionNotCreatedException(
                  "Attempt to start the underlying service more than once");
            }
            try {
              DriverService service = plan.getDriverService();
              serviceRef.set(service);
              service.start();
              return service.getUrl();
            } catch (IOException e) {
              throw new SessionNotCreatedException(e.getMessage(), e);
            }
          },
          plan::writePayload,
          () -> serviceRef.get().stop());
    } else {
      executor = new SpecCompliantExecutor(() -> remoteHost, plan::writePayload, () -> {});
    }

    return new RemoteWebDriver(executor, new ImmutableCapabilities());
  }
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();
    }
2885
@Override
    public Object createSession(ServletRequest req, ServletResponse res, SessionAffinityContext sac, boolean reuseTheId) {
        String id = _sam.getInUseSessionID(req, sac);
        int version = _sam.getInUseSessionVersion(req, sac); // sac.getRequestedSessionVersion();
        ISession isess = createISession(id, version, reuseTheId);
        return adaptAndSetCookie(req, res, sac, isess);
    }
278632
public void createSession(Session session) {
        sessionMap.put(session.id(), session);
        Event event = new Event();
        event.attribute("session", session);

        eventManager.fireEvent(EventType.SESSION_CREATED, event);
    }
265108
@SuppressWarnings("unchecked")
	public void sessionCreated(HttpSessionEvent se) {
		Descriptor<? extends Context> descriptor = container.contexts().get(Session.class);
		
		if (descriptor != null) {
			WebContext<HttpSession> context = (WebContext<HttpSession>) container.component(descriptor);
			context.associate(se.getSession());
		}
	}
974550
public ExpiryPolicyBuilder<K, V> create(Duration create) {
    Objects.requireNonNull(create, "Create duration cannot be null");
    if (create.isNegative()) {
      throw new IllegalArgumentException("Create duration must be positive");
    }
    return create((a, b) -> create);
  }
1164571
public SessionConfigType<WebAppType<T>> getOrCreateSessionConfig()
   {
      List<Node> nodeList = childNode.get("session-config");
      if (nodeList != null &&  nodeList.size() > 0)
      {
         return new SessionConfigTypeImpl<WebAppType<T>>(this, "session-config", childNode, nodeList.get(0));
      }
      return createSessionConfig();
   }