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

I don’t knwo the relationship between session_config, session_manager and session_storage.

According to document Session Manager - laminas-session - Laminas Docs

I made my configuration like:

'session_config' => [
        'cache_expire' => 60 * 24 * 30,
        'cookie_httponly' => true,
        'cookie_lifetime' => 86400 * 30,
        'gc_maxlifetime' => 86400 * 30,
        'name' => 'mysite',
        'remember_me_seconds' => 86400 * 30,
        'use_cookies' => true,
    ],
    'session_manager' => [
        'config' => [
            'class' => Laminas\Session\Config\SessionConfig::class,
            'options' => [
                'name' => 'mysite',
            ],
        ],
        'storage' => Laminas\Session\Storage\SessionArrayStorage::class,
        'validators' => [
            Laminas\Session\Validator\RemoteAddr::class,
            Laminas\Session\Validator\HttpUserAgent::class,
        ],
    ],

However when I inject like the following, it raise error

class ImagerotateauthController extends AbstractActionController
{
    public $sessionManager;

    public function __construct(SessionManager $sessionManager)
    {
        $this->sessionManager = $sessionManager;
    }

error:

Message:
Configuration is missing a "session_storage" key, or the value of that key is not an array

So I am confused about the relationship between them. even the others with session_manager
As we can see, in the key session_manager, it set config and storage and validator.
config should be session_config, storage should be session_storage, it seem I just need to config session_manager will be all ok.

I don’t know why, I am sure my understanding is incorrent, but really confused.

Besides, I found antoher page Usage in a laminas-mvc application - laminas-session - Laminas Docs
In this part, there is a full guide to config the session in the mvc mode.
However I still don’t know what’s the usage of the sessionManager. I used to new a session Container. not using sessionManager at all.

In this page Session Manager - laminas-session - Laminas Docs
It introduced a lot of code in module.php, what’s the usage of them?

This is the way you should go.

The session manager is used internally in the container and therefore you can ignore it.

Here we must read carefully:

The following illustrates how you might utilize the above configuration to create the session manager:

It does not say that you need or copy this. It only illustrates how the previous configuration looks like with full code.

(But this part is very misleading and I will remove it from the documentation.)

Did you use Container to manage sessions?

@froschdesign
Thanks for your reply!

All I need is to config the following keys in config/autoload/global.php

'session_containers' => [
        Laminas\Session\Container::class,
    ],
    'session_storage' => [
        'type' => Laminas\Session\Storage\SessionArrayStorage::class,
    ],
    'session_config' => [
        'cache_expire' => 60 * 24 * 30,
        'cookie_httponly' => true,
        'cookie_lifetime' => 86400 * 30,
        'gc_maxlifetime' => 86400 * 30,
        'name' => 'mm3bb',
        'remember_me_seconds' => 86400 * 30,
        'use_cookies' => true,
    ],
    'session_manager' => [
        'config' => [
            'class' => Laminas\Session\Config\SessionConfig::class,
            'options' => [
                'name' => 'mm3bb',
            ],
        ],
        'storage' => Laminas\Session\Storage\SessionArrayStorage::class,
        'validators' => [
            Laminas\Session\Validator\RemoteAddr::class,
            Laminas\Session\Validator\HttpUserAgent::class,
        ],
    ],

And then use container will be ok, forget about sessionManager

$container = new Container('api');

The above understanding is correct? I used session conatiner made a image captcha kind funtion, pls see Document, it works well.

Besides, I found a laminas-hidden inside web-browser cookie part

I am so sure that I didn’t set such a laminas-hidden key.
How can I remove this?

Besides, my personal website which I made as my homework www.mm3bb.com, use laminas-mvc, it seems running hardly because I rent a very week vps, the computing ability is very week, I think.
I don’t have much budget on it, it is the cheapest vps, I can only afford this.

They are not a human behavior, I think they are search engine which scrapy my data. when they crawl my site by second frequency, I feel the visiting of my site became very slow.

The images I scrapyed from others, now the database is very big, around 1,700,000 records.
Any suggestion on this? paginating very slow, the cpu and io both are very high level.

Did you wanted them to crawl every page? If you do not want them to do that, you can specify in the sitemap configuration for them to ignore certain path in your website.

There are a lot of factors that contribute to a slow website and a huge database table can be one of the contributing factors. Consider indexing the tables that is being queried in the pages that are slow. Also, use PageSpeed Insights to assess what other technical aspects that is causing the lag. If your website has a lot of media files (large images) that are not optimized, that could also be one of the reason and usually they would recommend you to lazy load your images.