public function find($id)
    {

        // return immediately if the requested session ID is empty
        if (empty($id)) {
            return;
        }

        // declare the session variable
        $session = null;

        // query whether or not the session with the passed ID exists
        if ($this->getSessions()->exists($id)) {
            $session = $this->getSessions()->get($id);

        } else {
            // iterate over the session handlers and try to un-persist the session
            /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */
            foreach ($this->getSessionHandlers() as $sessionHandler) {
                try {
                    if ($session = $sessionHandler->load($id)) {
                        $this->attach($session);
                        break;
                    }

                } catch (\Exception $e) {
                    // log the exception if a system logger is available
                    if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) {
                        // log the error message
                        $logger->error(sprintf('Can\'t load session data for session with ID "%s" because of: "%s"', $id, $e->getMessage()));
                        // log the stack trace in debug log level
                        $logger->debug($e->__toString());
                    }
                }
            }
        }

        // if we found a session, we've to check if it can be resumed
        if ($session instanceof ServletSessionInterface) {
            if ($session->canBeResumed()) {
                $session->resume();
                return $session;
            }
        }
    }
public function find($id)
    {

        // return immediately if the requested session ID is empty
        if (empty($id)) {
            return;
        }

        // declare the session variable
        $session = null;

        // query whether or not the session with the passed ID exists
        if ($this->getSessions()->exists($id)) {
            $session = $this->getSessions()->get($id);

        } else {
            // iterate over the session handlers and try to un-persist the session
            /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */
            foreach ($this->getSessionHandlers() as $sessionHandler) {
                try {
                    if ($session = $sessionHandler->load($id)) {
                        $this->attach($session);
                        break;
                    }

                } catch (\Exception $e) {
                    // log the exception if a system logger is available
                    if ($logger = $this->getLogger(LoggerUtils::SYSTEM)) {
                        // log the error message
                        $logger->error(sprintf('Can\'t load session data for session with ID "%s" because of: "%s"', $id, $e->getMessage()));
                        // log the stack trace in debug log level
                        $logger->debug($e->__toString());
                    }
                }
            }
        }

        // if we found a session, we've to check if it can be resumed
        if ($session instanceof ServletSessionInterface) {
            if ($session->canBeResumed()) {
                $session->resume();
                return $session;
            }
        }
    }
public function find ( $ id ) { // return immediately if the requested session ID is empty if ( empty ( $ id ) ) { return ; } // declare the session variable $ session = null ; // query whether or not the session with the passed ID exists if ( $ this -> getSessions ( ) -> exists ( $ id ) ) { $ session = $ this -> getSessions ( ) -> get ( $ id ) ; } else { // iterate over the session handlers and try to un-persist the session /** @var \AppserverIo\Appserver\ServletEngine\Session\SessionHandlerInterface $sessionHandler */ foreach ( $ this -> getSessionHandlers ( ) as $ sessionHandler ) { try { if ( $ session = $ sessionHandler -> load ( $ id ) ) { $ this -> attach ( $ session ) ; break ; } } catch ( \ Exception $ e ) { // log the exception if a system logger is available if ( $ logger = $ this -> getLogger ( LoggerUtils :: SYSTEM ) ) { // log the error message $ logger -> error ( sprintf ( 'Can\'t load session data for session with ID "%s" because of: "%s"' , $ id , $ e -> getMessage ( ) ) ) ; // log the stack trace in debug log level $ logger -> debug ( $ e -> __toString ( ) ) ; } } } } // if we found a session, we've to check if it can be resumed if ( $ session instanceof ServletSessionInterface ) { if ( $ session -> canBeResumed ( ) ) { $ session -> resume ( ) ; return $ session ; } } }
Tries to find a session for the given request. The session-ID will be
searched in the cookie header of the request, and in the request query
string. If both values are present, the value in the query string takes
precedence. If no session id is found, a new one is created and assigned
to the request.

@param string $id The unique session ID to that has to be returned

@return \AppserverIo\Psr\Servlet\ServletSessionInterface|null The requested session
Tries to find a session for the given request . The session - ID will be searched in the cookie header of the request and in the request query string . If both values are present the value in the query string takes precedence . If no session id is found a new one is created and assigned to the request .