Question

I'm getting comfortable with the Lithium framework, and was wondering if there were any samples for using MongoDB or Memcache for Lithium Sessions. Would there need to be a new Session Adapter written?

Was it helpful?

Solution

One option is to set the session adapter to 'Php' in lithium and pass 'session.save_handler' => 'memcached' to the config options which will use the memcached extension's save handler to store sessions in memcache:

Session::config(array(
    'default' => array(
        'adapter' => 'Php',
        'session.save_handler' => 'memcached',
        'session.save_path' => 'sess1:11211, sess2:11211'
    )
));

http://php.net/manual/en/memcached.sessions.php

I store sessions in MongoDb by using the 'Model' adapter (which is available on lab.lithify.me):

Session::config(array(
    'default' => array(
        'adapter' => 'Model',
        'model' => 'app\models\Sessions',
        'name' => 'session'
    )
));

http://lab.lithify.me/lab/extensions/view/a68f6ad626aaf7be37805f8e72f672e2

OTHER TIPS

New adapters must be written for those:

Unless you keep using the PHP adapter and leverage session_set_save_handler which just got better in PHP 5.4.

I'd go with the second solution.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top