CodeIgniter Forums
Mongo DB | Saving Session States on a DB Cluster - Printable Version

+- CodeIgniter Forums (https://forum.codeigniter.com)
+-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20)
+--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23)
+--- Thread: Mongo DB | Saving Session States on a DB Cluster (/showthread.php?tid=43736)



Mongo DB | Saving Session States on a DB Cluster - El Forum - 07-21-2011

[eluser]jtmgdevelopment[/eluser]
Hi,

I am building an app that requires the use of a database cluster. We are using MongoDB to manage this. Most of my data actions are using an API; however, in order to store session information I am required to use MongoDB as a session handler. This is requiring my to instantiate the on and only at application start:
Code:
$conf = array(
    'servers' => array('db1.mystery.com:5555', 'db2.mystery.com:55555', 'db3.db1.mystery.com:5555.com:555555', 'db4.mystery.com:55555'),
    'options' => array('persist' => 'mongo-session', 'replicaSet' => true )
    );
    
require $params[1];
require_once(MONGOSESSION);
        
MongoSessionHandler::register('mystery', 'sessions_website', $conf);

Where should I place this code at so I can create sessions that will be stored using MongoDB? My call to the database cluster will consist of sending a unique session id everytime I call the api.

Code:
$ret = $dispatch->loadPersonFromSession($session_id)->execute($data);

Any help would be appreciated.


Mongo DB | Saving Session States on a DB Cluster - El Forum - 07-21-2011

[eluser]icomefromthenet[/eluser]
I would override the session class, create your own using mongo. There is a section in the user guide on overriding libraries