Need help for middleware orchestration Twig, Cas, sessionMiddleware

Finally I found the solution

I kept middleware.php with this init :

$app->add(TwigMiddleware::createFromContainer(
    $app,
    \Slim\Views\Twig::class
));

and I set the session with this : Accessing _SESSION variable in TWIG - #10 by odan