/*
get the requested session id
330171
public String getRequestedSessionId(HttpServletRequest _request)
  {
    SessionAffinityContext sac = getSessionAffinityContext(_request);
      
    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
      LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[GET_REQUESTED_SESSION_ID], sac.isFirstSessionIdValid());
    }

    String reqSessId = sac.getRequestedSessionID();

    // if we have multiple session ids, the "requested" one is either the
    // first one that is valid, or if none are valid, the first one in the list
    boolean idIsValid = _coreHttpSessionManager.isRequestedSessionIDValid(reqSessId, 0);

    // getSession may or may not have been called. We need to check if the first
    // id is valid and if not, then check if we need to update the allSessionIds
    // list
    if (reqSessId != null && !idIsValid && !sac.isAllSessionIdsSetViaSet()
                    || !sac.isAllSessionIdsSetViaSet() && !sac.isFirstSessionIdValid()) { //PM89885 added || condition
      List allSessionIds = _sam.getAllCookieValues(_request);
      sac.setAllSessionIds(allSessionIds);
    }

    if (sac.getNumSessionIds() > 1)
    {
      if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE))
      {
        LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[GET_REQUESTED_SESSION_ID], "multiple incoming ids");
      }
      while (!idIsValid && _sam.setNextId(sac))
      {
        reqSessId = sac.getRequestedSessionID();
        idIsValid = _coreHttpSessionManager.isRequestedSessionIDValid(reqSessId, 0);
      }
      if (!idIsValid)
      {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE))
        {
          LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[GET_REQUESTED_SESSION_ID], "none valid - return first");
        }
        reqSessId = sac.getFirstRequestedSessionID();
      }
    } else if (!idIsValid && !sac.isFirstSessionIdValid()){
        // Only session available is the one sent from the client so return that one
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled()&&LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
          LoggingUtil.SESSION_LOGGER_CORE.logp(Level.FINE, methodClassName, methodNames[GET_REQUESTED_SESSION_ID], "return the only one id sent from client");
        }
        reqSessId = sac.getFirstRequestedSessionID();
    }
    if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE))
    {
      LoggingUtil.SESSION_LOGGER_CORE.exiting(methodClassName, methodNames[GET_REQUESTED_SESSION_ID], reqSessId);
    }
    return reqSessId;
  }
810373
protected Long getPersistedSessionId(String location, String identifier) {
        File sessionIdStore = new File(location + File.separator + identifier+ "-jbpmSessionId.ser");
        if (sessionIdStore.exists()) {
        	Long knownSessionId = null; 
            FileInputStream fis = null;
            ObjectInputStream in = null;
            try {
                fis = new FileInputStream(sessionIdStore);
                in = new ObjectInputStream(fis);
                
            	Object tmp = in.readObject();
            	if (tmp instanceof Integer) {
            		tmp = new Long((Integer) tmp);
            	}
        		knownSessionId = (Long) tmp;
                
                return knownSessionId.longValue();
                
            } catch (Exception e) {
                return 0L;
            } finally {
                if (in != null) {
                    try {
                        in.close();
                    } catch (IOException e) {
                    }
                }
                if (fis != null) {
                    try {
                        fis.close();
                    } catch (IOException e) {
                    }
                }
 
            }
            
        } else {
            return 0L;
        }
    }
763850
protected function getSessionId() {
    // check if we already have a session with the server
    $session = ObjectFactory::getInstance('session');
    $sids = $session->get(self::SIDS_SESSION_VARNAME);
    if (isset($sids[$this->serverCli])) {
      return $sids[$this->serverCli];
    }
    return null;
  }
389898
public function getSessionId() : string
    {
        //if its empty get it from the relationship, else get it from the property
        return empty($this->session_id) ? $this->getSession(['order' => 'time desc'])->session_id : $this->session_id;
    }
311364
function(callback){
			if(!this.id){
				return process.nextTick(function(){
					callback(new Error("Invalid session ID"));
				});
			}
			options.client.expire(options.keyspace + this.id, options.maxAge, callback);
		}
911753
public static String getSessionId(final HttpServletRequest pRequest) {
        HttpSession session = pRequest.getSession();

        return (session != null) ? session.getId() : null;
    }
160507
protected function getSidFromRequest()
    {
        $myConfig = \OxidEsales\Eshop\Core\Registry::getConfig();
        $sid = null;

        $sForceSidParam = $myConfig->getRequestParameter($this->getForcedName());
        $sSidParam = $myConfig->getRequestParameter($this->getName());

        //forcing sid for SSL<->nonSSL transitions
        if ($sForceSidParam) {
            $sid = $sForceSidParam;
        } elseif ($this->_getSessionUseCookies() && $this->_getCookieSid()) {
            $sid = $this->_getCookieSid();
        } elseif ($sSidParam) {
            $sid = $sSidParam;
        }

        return $sid;
    }
597886
public function getProposedSessionId()
    {

        // if no session has already been load, initialize the session manager
        /** @var \AppserverIo\Appserver\ServletEngine\SessionManagerInterface $manager */
        $manager = $this->getContext()->search(SessionManagerInterface::IDENTIFIER);

        // if no session manager was found, we don't support sessions
        if ($manager == null) {
            return;
        }

        // if we can't find a requested session name, we try to load the default session cookie
        if ($this->getRequestedSessionName() == null) {
            $this->setRequestedSessionName($manager->getSessionSettings()->getSessionName());
        }

        // load the requested session ID and name
        $sessionName = $this->getRequestedSessionName();
        $id = $this->getRequestedSessionId();

        // try to load session ID from session cookie of request/response
        $cookieFound = null;
        if ($id == null && $this->getResponse()->hasCookie($sessionName)) {
            $cookieFound = $this->getResponse()->getCookie($sessionName);
        } elseif ($id == null && $this->hasCookie($sessionName)) {
            $cookieFound = $this->getCookie($sessionName);
        }

        // check if we can find a cookie
        if (is_array($cookieFound)) {
            // iterate over the cookies and try to find one that is not expired
            foreach ($cookieFound as $cookie) {
                if ($cookie instanceof CookieInterface && $cookie->isExpired() === false) {
                    $this->setRequestedSessionId($id = $cookie->getValue());
                }
            }

        // if we found a single cookie instance
        } elseif ($cookieFound instanceof CookieInterface && $cookieFound->isExpired() === false) {
            $this->setRequestedSessionId($id = $cookieFound->getValue());
        }

        // return the requested session
        return $id;
    }
1060647
public static function sessionId($id = null)
    {
        if (PHP_SAPI != 'cli') {
            return $id ? session_id($id) : session_id();
        }
        if (static::sessionStarted() && HttpCache::$instance->sessionFile) {
            return str_replace('ses_', '', basename(HttpCache::$instance->sessionFile));
        }
        return '';
    }
108885
public HttpSessionImpl getSession(final String sessionId) {
        final SessionManager sessionManager = deployment.getSessionManager();
        Session session = sessionManager.getSession(sessionId);
        if (session != null) {
            return SecurityActions.forSession(session, this, false);
        }
        return null;
    }
976425
public String generateSessionId()
    {

        byte random[] = new byte[16];

        // Render the result as a String of hexadecimal digits
        StringBuilder buffer = new StringBuilder();

        int resultLenBytes = 0;

        while (resultLenBytes < sessionIdLength)
        {
            getRandomBytes(random);
            for (int j = 0;
                    j < random.length && resultLenBytes < sessionIdLength;
                    j++)
            {
                byte b1 = (byte) ((random[j] & 0xf0) >> 4);
                byte b2 = (byte) (random[j] & 0x0f);
                if (b1 < 10)
                {
                    buffer.append((char) ('0' + b1));
                }
                else
                {
                    buffer.append((char) ('A' + (b1 - 10)));
                }
                if (b2 < 10)
                {
                    buffer.append((char) ('0' + b2));
                }
                else
                {
                    buffer.append((char) ('A' + (b2 - 10)));
                }
                resultLenBytes++;
            }
        }

        if (jvmRoute != null && jvmRoute.length() > 0)
        {
            buffer.append('.').append(jvmRoute);
        }

        return buffer.toString();
    }
414965
public function getSessionData($session_id = '')
    {
        if (isset($this->objectSession) && $this->objectSession != NULL && is_object($this->objectSession)) {
            $this->logger->info(__FUNCTION__, 'Session with CI Session Class');
            if ($this->objectSession->has_userdata($session_id)) {
                return $this->objectSession->userdata($session_id);
            }
        } else {
            $this->logger->info(__FUNCTION__, 'Session with The Http Foundation Component');
            if ($this->session->has($session_id)) {
                return $this->session->get($session_id);
            }
        }

        return NULL;
    }
1287801
public String getRequestedSessionIdFromURL(ServletRequest request) {
        if (com.ibm.ejs.ras.TraceComponent.isAnyTracingEnabled() && LoggingUtil.SESSION_LOGGER_CORE.isLoggable(Level.FINE)) {
            LoggingUtil.SESSION_LOGGER_CORE.entering(methodClassName, methodNames[GET_REQUESTED_SESSION_ID_FROM_URL]);
        }
        String sessionID = null;
        // LIBERTY Cannot reach IExtendedRequest from here anymore
        // overridden in SessionAffinityManagerImpl
        return null;
    }
371725
protected function loadClientSessionId(): string
    {
        $sessionId = '';
        if (isset($_COOKIE[$this->cookieName])) {
            $sessionId = $_COOKIE[$this->cookieName];
        }
        if ($sessionId == '') {
            return $sessionId;
        }
        if ($this->isValidSessionId($sessionId)) {
            return $sessionId;
        } else {
            return '';
        }
    }
424092
public static Session getSession(int dbId, long sessionId) {

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

        return db == null ? null
                          : db.sessionManager.getSession(sessionId);
    }
330956
protected function getBrokerSessionID()
        {
            $headers = getallheaders();

            if (isset($headers['Authorization']) &&  strpos($headers['Authorization'], 'Bearer') === 0) {
                $headers['Authorization'] = substr($headers['Authorization'], 7);
                return $headers['Authorization'];
            }
            if (isset($_GET['access_token'])) {
                return $_GET['access_token'];
            }
            if (isset($_POST['access_token'])) {
                return $_POST['access_token'];
            }
            if (isset($_GET['sso_session'])) {
                return $_GET['sso_session'];
            }

            return false;
        }
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);
    }