src/SessionMiddleware.php
public static function getSession(ServerRequestInterface $request):SessionDataHolder
    {
        $session = $request->getAttribute(static::REQ_ATTR);
        if (!$session instanceof SessionDataHolder) {
            throw new SessionMiddlewareException(
                "No session object is available in the request attributes"
            );
        }
        return $session;
    }
public static function getSession(ServerRequestInterface $request):SessionDataHolder
    {
        $session = $request->getAttribute(static::REQ_ATTR);
        if (!$session instanceof SessionDataHolder) {
            throw new SessionMiddlewareException(
                "No session object is available in the request attributes"
            );
        }
        return $session;
    }
Returns the session object attached to a request.

@param ServerRequestInterface $request
@return SessionDataHolder
@throws SessionMiddlewareException