Skip to content

Instantly share code, notes, and snippets.

@rmarscher
Created May 30, 2012 23:18
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 rmarscher/2839513 to your computer and use it in GitHub Desktop.
Save rmarscher/2839513 to your computer and use it in GitHub Desktop.
Lithium session config for operating on only one configuration by default
<?php
use lithium\storage\Session;
$methods = array('read', 'write', 'delete', 'clear', 'check');
foreach ($methods as $method) {
$filter = function($self, $params, $chain) use ($method) {
if ($params['options']['name'] === null) {
if ($params['configuration'] !== 'default') {
// dump("returning false for {$params['configuration']} for {$method}");
return false;
}
}
// dump("continuing with {$params['configuration']} for {$method}");
return $chain->next($self, $params, $chain);
};
Session::applyFilter($method, $filter);
}
$default = array(
'adapter' => 'Model',
'model' => 'app\models\Sessions',
'name' => 'session',
'cookie_lifetime' => 0,
'gc_maxlifetime' => 21600
);
$cookie = array(
'adapter' => 'Cookie',
'name' => 'anon',
'expire' => '+1 year',
'strategies' => array('Encrypt' => array('secret' => '!!removed!!'))
);
Session::config(compact('default', 'cookie'));
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment