Creates a new session with the given id. If null is used, an automatic
session id will be generated

@param sessionId The new session id. Must be unique.
@throws PMException on already defined session
@return New session
336774
public PMSession registerSession(String sessionId) {
        synchronized (sessions) {
            if (sessionId != null) {
                if (!sessions.containsKey(sessionId)) {
                    sessions.put(sessionId, new PMSession(sessionId));
                }
                return getSession(sessionId);
            } else {
                return registerSession(newSessionId());
            }
        }
    }
1360797
@Nonnull
	public String createSessionId( @Nonnull final String sessionId ) {
		return isEncodeNodeIdInSessionId() ? _sessionIdFormat.createSessionId(sessionId,  _nodeIdService.getMemcachedNodeId() ) : sessionId;
	}
652325
@Override
  public AppSession getSession(String sessionId, Class<? extends AppSession> aClass) {
    if (sessionId == null) {
      throw new IllegalArgumentException("SessionId must not be null");
    }
    if (!this.iss.exists(sessionId)) {
      return null;
    }
    AppSession appSession = null;
    try {
      if (aClass == ServerRfSession.class) {
        IServerRfSessionData sessionData = (IServerRfSessionData) this.sessionDataFactory.getAppSessionData(ServerRfSession.class, sessionId);
        // FIXME: determine how to get boolean flag!
        ServerRfSessionImpl session = new ServerRfSessionImpl(sessionData, sessionFactory, getServerSessionListener(), getServerContextListener(),
            getStateListener(), messageTimeout, true);

        session.getSessions().get(0).setRequestListener(session);
        appSession = session;
      }
      else if (aClass == ClientRfSession.class) {
        IClientRfSessionData sessionData = (IClientRfSessionData) this.sessionDataFactory.getAppSessionData(ClientRfSession.class, sessionId);
        ClientRfSessionImpl session = new ClientRfSessionImpl(sessionData, sessionFactory, getClientSessionListener(), getClientContextListener(),
            getStateListener(), this.getApplicationId());

        session.getSessions().get(0).setRequestListener(session);
        appSession = session;
      }
      else {
        throw new IllegalArgumentException("Wrong session class: " + aClass + ". Supported[" + ClientRfSession.class + "," + ServerRfSession.class + "]");
      }
    }
    catch (Exception e) {
      logger.error("Failure to obtain new Rf Session.", e);
    }

    return appSession;
  }
127552
public static Session create(SessionStore sessionStore, HttpRequest<?> request) {
        Session session = sessionStore.newSession();
        request.getAttributes().put(HttpSessionFilter.SESSION_ATTRIBUTE, session);
        return session;
    }
578968
private function _getSession($sessionId)
    {
        if (is_null($this->_session)) {
            $this->_session = $this->_repository->find(array('sessionId' => $sessionId));
        }

        return $this->_session;
    }
406801
public synchronized USER remove(final ID sessionId)
	{
		final USER user = getUser(sessionId);
		if (user != null)
		{
			usersOnline.remove(user);
		}
		sessionIdToUser.remove(sessionId);
		return user;
	}
957632
public String getNewSessionIdIfNodeFromSessionIdUnavailable( @Nonnull final String sessionId ) {
		if ( isEncodeNodeIdInSessionId() ) {
	        final String nodeId = _sessionIdFormat.extractMemcachedId( sessionId );
	        final String newNodeId = _nodeIdService.getNewNodeIdIfUnavailable( nodeId );
	        if ( newNodeId != null ) {
	            return _sessionIdFormat.createNewSessionId( sessionId, newNodeId);
	        }
		}
		return null;
	}
424092
public static Session getSession(int dbId, long sessionId) {

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

        return db == null ? null
                          : db.sessionManager.getSession(sessionId);
    }
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;
        }
    }
348948
void setId(String sessionAuthId) {
        synchronized (lock) {
            if (isCreatingSession.get()) {
                this.sessionAuthId = sessionAuthId;
            }
            lock.notifyAll();
        }
    }
757436
public ISession createSession(String sessionId, boolean newId) {
        //create local variable - JIT performance improvement
        final boolean isTraceOn = com.ibm.websphere.ras.TraceComponent.isAnyTracingEnabled();
        //need some way to checkForDuplicateCreatedIds or synchronize on some object or something ... look at in-memory
        if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            StringBuffer sb = new StringBuffer("id = ").append(sessionId).append(appNameForLogging);
            LoggingUtil.SESSION_LOGGER_WAS.entering(methodClassName, methodNames[CREATE_SESSION], sb.toString());
        }
        if (inProcessOfStopping) {
            throwException("SessionContext.createWhenStop");
        }
        BackedSession session = null;
        session = createSessionObject(sessionId);
        session.updateLastAccessTime(session.getCreationTime());
        session.setInsert(); // flag new session for insertion into store
        session.setMaxInactiveInterval((int) _smc.getSessionInvalidationTime());
        session.setUserName(ANONYMOUS_USER);
        _sessions.put(sessionId, session);
        //        if (session.duplicateIdDetected) { // could happen on zOS if key is defined incorrectly - perhaps doesn't include appname
        //                                           // other than that, this really should never happen - duplicate ids should not be generated
        //            LoggingUtil.SESSION_LOGGER_CORE.logp(Level.WARNING, methodClassName, methodNames[CREATE_SESSION], "Store.createSessionIdAlreadyExists");
        //            session = null;
        //        }

        if (isTraceOn && LoggingUtil.SESSION_LOGGER_WAS.isLoggable(Level.FINER)) {
            LoggingUtil.SESSION_LOGGER_WAS.exiting(methodClassName, methodNames[CREATE_SESSION], "session = " + session);
        }
        return session;
    }
1102573
public static synchronized MCAAuthorizationManager createInstance(Context context, String tenantId) {
        instance = createInstance(context);
        if (null != tenantId) {
            instance.tenantId = tenantId;
        }
        return instance;

    }
933540
@Nonnull
    public String createLockName( @Nonnull final String sessionId ) {
        if ( sessionId == null ) {
            throw new IllegalArgumentException( "The sessionId must not be null." );
        }
        return "lock:" + _storageKeyFormat.format(sessionId);
    }
1235468
public GetSessionSourceInfoResponse getSessionSourceInfo(String sessionId) {
        checkStringNotEmpty(sessionId, "The parameter sessionId should NOT be null or empty string.");
        GetSessionSourceInfoRequest request = new GetSessionSourceInfoRequest();
        InternalRequest internalRequest = createRequest(HttpMethodName.GET, request, LIVE_SESSION, sessionId);
        internalRequest.addParameter(SOURCE_INFO, null);
        return invokeHttpClient(internalRequest, GetSessionSourceInfoResponse.class);
    }
363825
public HttpSession generateNewId(WebApp webapp) {
        HttpSession existingSession = (HttpSession) webappToSessionMap.get(webapp);
        if (existingSession != null) {
            if (!webapp.getSessionContext().isValid(existingSession, request, false)) {
                existingSession = null;
            }
        } else {
            // Looks like the session wasn't obtained during the preinvoke
            // call.  Should only happen if session doesn't exist at preinvoke.
            existingSession = webapp.getSessionContext().getIHttpSession(request, (HttpServletResponse) request.getResponse(), false);                
        }
        if ( existingSession == null) {
            if (TraceComponent.isAnyTracingEnabled() && tc.isErrorEnabled()) {  
                Tr.error(tc, "changeSessionId.no.session.associated.with.request", new Object[] {request.getRequestURI()});
            }
            throw new IllegalStateException(Tr.formatMessage(tc, "changeSessionId.no.session.associated.with.request", request.getRequestURI()));
        }
        
        HttpSession session = ((HttpSessionContext31Impl)webapp.getSessionContext()).generateNewId(request, (HttpServletResponse) request.getResponse(), existingSession);
        
        return session;
    }
1120860
public UserEntity createNewUser(String userId) {
    checkAuthorization(Permissions.CREATE, Resources.USER, null);
    return new UserEntity(userId);
  }
657248
private CmsUgcSession createSession(CmsObject cms, CmsUgcConfiguration config) throws CmsUgcException {

        if (getQueue(config).waitForSlot()) {
            try {
                return new CmsUgcSession(m_adminCms, cms, config);
            } catch (CmsException e) {
                LOG.error(e.getLocalizedMessage(), e);
                throw new CmsUgcException(e);
            }
        } else {
            String message = Messages.get().container(Messages.ERR_WAIT_QUEUE_EXCEEDED_0).key(
                cms.getRequestContext().getLocale());
            throw new CmsUgcException(CmsUgcConstants.ErrorCode.errMaxQueueLengthExceeded, message);
        }
    }