manage session init as a stack middleware