Skip to content

Instantly share code, notes, and snippets.

@cballou
Created June 5, 2016 19:21
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save cballou/b4f6117e0b4e4929f249336e8225d7f4 to your computer and use it in GitHub Desktop.
Save cballou/b4f6117e0b4e4929f249336e8225d7f4 to your computer and use it in GitHub Desktop.
MongoSession example usage
<?php
require_once('MongoSession.php');
// the config array for loading MongoDB servers
$config = array(
// cookie related vars
'cookie_path' => '/',
'cookie_domain' => '.mydomain.com', // .mydomain.com
// session related vars
'lifetime' => 3600, // session lifetime in seconds
'database' => 'session', // name of MongoDB database
'collection' => 'session', // name of MongoDB collection
// array of mongo db servers
'servers' => array(
array(
'host' => Mongo::DEFAULT_HOST,
'port' => Mongo::DEFAULT_PORT,
'username' => null,
'password' => null,
'persistent' => false
)
)
);
$session = new MongoSession($config);
<?php
require_once('MongoSession.php');
$session = new MongoSession();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment