Configuration is missing a "session_config" key, or the value of that key is not an array

I’ve downloaded the 1.2.x skeleton app and build + run it with docker-compose.
It’s working, When I open my browser, I see the default laminas skeleton webpage.

Next thing I wanted to to do was implement sessions. So I tried both the examples from the documentation as well as this zf3 guide : Session Manager – Using Zend Framework 3

So, I added

return [
    // Session configuration.
    'session_config' => [
        // Session cookie will expire in 1 hour.
        'cookie_lifetime' => 60*60*1,     
        // Session data will be stored on server maximum for 30 days.
        'gc_maxlifetime'     => 60*60*24*30, 
    ],
    // Session manager configuration.
    'session_manager' => [
        // Session validators (used for security).
        'validators' => [
            RemoteAddr::class,
            HttpUserAgent::class,
        ]
    ],
    // Session storage configuration.
    'session_storage' => [
        'type' => SessionArrayStorage::class
    ],
    
    // ...
];

to config/autoload/global.php and then added this

/**
 * This method is called once the MVC bootstrapping is complete. 
 */
public function onBootstrap(MvcEvent $event)
{
    $application = $event->getApplication();
    $serviceManager = $application->getServiceManager();
    
    // The following line instantiates the SessionManager and automatically
    // makes the SessionManager the 'default' one.
    $sessionManager = $serviceManager->get(SessionManager::class);
}

to the Module class.

When I reload the index page I get the error:

Fatal error : Uncaught Laminas\ServiceManager\Exception\ServiceNotCreatedException: Configuration is missing a “session_config” key, or the value of that key is not an array in /var/www/vendor/laminas/laminas-session/src/Service/SessionConfigFactory.php:39 Stack trace: #0 /var/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(665): Laminas\Session\Service\SessionConfigFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), ‘Laminas\Session…’, NULL) #1 /var/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(230): Laminas\ServiceManager\ServiceManager->doCreate(‘Laminas\Session…’) #2 /var/www/vendor/laminas/laminas-session/src/Service/SessionManagerFactory.php(74): Laminas\ServiceManager\ServiceManager->get(‘Laminas\Session…’) #3 /var/www/vendor/laminas/laminas-servicemanager/src/ServiceManager.php(665): Laminas\Session\Service\SessionManagerFactory->__invoke(Object(Laminas\ServiceManager\ServiceManager), ‘Laminas\Session…’, Array) #4 /var/www/vendor/laminas/laminas-servicema in /var/www/vendor/laminas/laminas-session/src/Service/SessionConfigFactory.php on line 39

I have the feeling this is because the config in global.php is not loaded, because if I put garbage in that file, I don’t get any parse error. I’ve also tried putting it in a global.config.php file, but with the same result.

I’m probably overlooking something very silly, but I can’t find what it is. These are the only two modifications I’ve made with a clean skeleton app, so nothing else could be in the way.

Please check that the cache is disabled for development.

The module class needs no extension. Add the following to your config and the created session manager will be set as default for session container:

return [
    'session_manager' => [
        'enable_default_container_manager' => true,
        // …
    ],
    // …
];

Wow :slight_smile:
I had been focussing on the sessions with a clean checkout because that was my main problem, but this has magically solved all the other problems I was having too! :slight_smile:
Thank you so much! :pray:

Thanks for the feedback. I will update the official documentation because it is not helpful on this topic.