public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Fail when session is disabled or has already started.
        $this->failWhenDisabled();
        $this->failWhenStarted();

        // Try to retrieve the session id from the request cookies.
        $cookies = $request->getCookieParams();

        $session_id = $cookies[$this->name] ?? '';

        if ($session_id != '') session_id($session_id);

        // Handle the request when session_start is successful.
        if (session_start(self::SESSION_OPTIONS)) {

            session_name($this->name);

            $response = $handler->handle($request);

            $this->failWhenClosed();

            $session_id = session_id();

            session_write_close();

            return $this->withSessionCookie($response, $session_id);

        }

        throw new SessionStartException;
    }
public function process(ServerRequestInterface $request, RequestHandlerInterface $handler): ResponseInterface
    {
        // Fail when session is disabled or has already started.
        $this->failWhenDisabled();
        $this->failWhenStarted();

        // Try to retrieve the session id from the request cookies.
        $cookies = $request->getCookieParams();

        $session_id = $cookies[$this->name] ?? '';

        if ($session_id != '') session_id($session_id);

        // Handle the request when session_start is successful.
        if (session_start(self::SESSION_OPTIONS)) {

            session_name($this->name);

            $response = $handler->handle($request);

            $this->failWhenClosed();

            $session_id = session_id();

            session_write_close();

            return $this->withSessionCookie($response, $session_id);

        }

        throw new SessionStartException;
    }
public function process ( ServerRequestInterface $ request , RequestHandlerInterface $ handler ) : ResponseInterface { // Fail when session is disabled or has already started. $ this -> failWhenDisabled ( ) ; $ this -> failWhenStarted ( ) ; // Try to retrieve the session id from the request cookies. $ cookies = $ request -> getCookieParams ( ) ; $ session_id = $ cookies [ $ this -> name ] ?? '' ; if ( $ session_id != '' ) session_id ( $ session_id ) ; // Handle the request when session_start is successful. if ( session_start ( self :: SESSION_OPTIONS ) ) { session_name ( $ this -> name ) ; $ response = $ handler -> handle ( $ request ) ; $ this -> failWhenClosed ( ) ; $ session_id = session_id ( ) ; session_write_close ( ) ; return $ this -> withSessionCookie ( $ response , $ session_id ) ; } throw new SessionStartException ; }
Start the session, handle the request and add the session cookie to the
response.

@param \Psr\Http\Message\ServerRequestInterface  $request
@param \Psr\Http\Server\RequestHandlerInterface  $handler
@return \Psr\Http\Message\ResponseInterface
@throws \Ellipse\Session\Exceptions\SessionStartException
Start the session handle the request and add the session cookie to the response .