1. Go to this page and download the library: Download substacks/mongosession library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
substacks / mongosession example snippets
$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
// persistent related vars
'persistent' => false, // persistent connection to DB?
'persistentId' => 'MongoSession', // name of persistent connection
// whether we're supporting replicaSet
'replicaSet' => false,
// array of mongo db servers
'connectionString' => 'mongodb://USER:PASSWORD@HOST:PORT/Database'
);
$session = new MongoSession($config);
public function gc()
{
// define the query
$query = array('expiry' => array('$lt' => time()));
// update options
$options = array(
'justOne' => TRUE,
'safe' => TRUE,
'fsync' => TRUE
);
// update expired elements and set to inactive
$this->_mongo->remove($query, $options);
return true;
}
` PHP
// include the session handler
Session();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.