Documentation

MongoDB — Zend Framework 2 2.1.5 documentation

MongoDB

Zend\Session\SaveHandler\MongoDB allows you to provide a MongoDB instance to be utilized as a session save handler. You provide the options in the Zend\Session\SaveHandler\MongoDBOptions class.

Basic Usage

A basic example is one like the following:

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
use Mongo;
use Zend\Session\SaveHandler\MongoDB;
use Zend\Session\SaveHandler\MongoDBOptions;
use Zend\Session\SessionManager;

$mongo = new Mongo();
$options = new MongoDBOptions(array(
    'database' => 'myapp',
    'collection' => 'sessions',
));
$saveHandler = new MongoDB($mongo, $options);
$manager = new SessionManager();
$manager->setSaveHandler($saveHandler);

Copyright

© 2006-2020 by Zend by Perforce. Made with by awesome contributors.

This website is built using zend-expressive and it runs on PHP 7.

Contacts