Custom Session handler doesn't work

I’m trying to use custom session handler using Google Datastore. There is a part of code of main module:

 public function onBootstrap(MvcEvent $e)
    $sessionConfig = new SessionConfig();

    $sessionManager = new SessionManager($sessionConfig);


    $sessionsStorage = $e->getApplication()->getServiceManager()->get('CustomSessionStorage\Storage\CustomStorage');



But it doesn’t work. Sessions are still using files on server and method “SessionHandlerInterface::open” is never called.

But when I write this code (in the same place onBootstrap), session handler is used and methods “open”, “read” etc is used. Why the first code doesn’t work?

session_set_save_handler($sessionsStorage->createHandler(), true);

How to use my custom handler?

I’ve added logging in SessionManager::start
I’ve got the following

Since you’re manually creating your SessionManager instance anyways… have you tried this:

$sessionManager = new SessionManager(

My suspicion is that the default PHP save handler is getting initialized somehow during SessionManager construction, so if you can inject the new handler then, it may work.

Unfortunately it didn’t help (