Moved session set handler out of the Session class.

This commit is contained in:
Josh Sherman 2011-01-20 20:45:48 -05:00
parent 8206239d59
commit 24770b2e9c
2 changed files with 13 additions and 13 deletions

View file

@ -108,9 +108,9 @@ class Session extends Object
* Constructor
*
* All of our set up logic for the session in contained here. This object
* is initially instantiated from pickles.php and does nothing more than
* the instantiation. All variables are driven from php.ini and/or the
* site config. Once configured, the session is started
* is initially instantiated and the event handler is set from pickles.php
* All variables are driven from php.ini and/or the site config. Once
* configured, the session is started automatically.
*/
public function __construct()
{
@ -130,16 +130,6 @@ class Session extends Object
// Gets a database instance
$this->db = Database::getInstance($this->datasource);
// Sets up the session handler
session_set_save_handler(
array($this, 'open'),
array($this, 'close'),
array($this, 'read'),
array($this, 'write'),
array($this, 'destroy'),
array($this, 'gc')
);
register_shutdown_function('session_write_close');
session_start();
}

View file

@ -95,6 +95,16 @@ if (isset($config->pickles['session']))
if (isset($_REQUEST['request']) == false || preg_match('/^__pickles\/(css|js)\/.+$/', $_REQUEST['request']) == false)
{
$session = new Session();
// Sets up the session handler
session_set_save_handler(
array($session, 'open'),
array($session, 'close'),
array($session, 'read'),
array($session, 'write'),
array($session, 'destroy'),
array($session, 'gc')
);
}
}
}