# Configuration is missing a "session\_config" key, or the value of that key is not an array

**URL:** <https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106>\
**Category:** Components & MVC\
**Tags:** laminas-mvc, laminas-session\
**Created:** [February 14, 2021, 10:18pm UTC](https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106 "2021-02-14T22:18:45Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![marty](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@marty](https://discourse.laminas.dev/u/marty)\
**Post date:** [February 14, 2021, 10:18pm UTC](https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106/1 "2021-02-14T22:18:45Z")

</div>

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](https://olegkrivtsov.github.io/using-zend-framework-3-book/html/en/Working_with_Sessions/Session_Manager.html)

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.

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 15, 2021, 7:27pm UTC](https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106/2 "2021-02-15T19:27:05Z")

</div>

> [@marty](#):
>
> 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.

Please check that the cache is [disabled for development](https://github.com/laminas/laminas-development-mode).

> [@marty](#):
>
> …to the Module class.

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](https://docs.laminas.dev/laminas-session/container/#setting-the-default-session-manager):

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

```

---

<div class="post-metadata">

**Author:** ![marty](https://avatars.discourse-cdn.com/v4/letter/m/f0a364/32.png) [@marty](https://discourse.laminas.dev/u/marty)\
**Post date:** [February 15, 2021, 9:08pm UTC](https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106/3 "2021-02-15T21:08:40Z")

</div>

> [@froschdesign](#):
>
> Please check that the cache is [disabled for development](https://github.com/laminas/laminas-development-mode).

Wow 🙂  
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! 🙂  
Thank you so much! 🙏

---

<div class="post-metadata">

**Author:** ![froschdesign](https://yyz2.discourse-cdn.com/flex032/user_avatar/discourse.laminas.dev/froschdesign/32/38_2.png) [@froschdesign](https://discourse.laminas.dev/u/froschdesign)\
**Post date:** [February 16, 2021, 9:41am UTC](https://discourse.laminas.dev/t/configuration-is-missing-a-session-config-key-or-the-value-of-that-key-is-not-an-array/2106/4 "2021-02-16T09:41:43Z")

</div>

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