Session stack middleware.