Session Class
Provides session handling via database instead of the file based session handling built into PHP. Using this class requires an array to be defined in place of the boolean true/false (on/off). If simply array(), the datasource will default to the value in $config['pickles']['datasource'] and if the table will default to "sessions". The format is as follows:
$config = array( 'pickles' => array( 'session' => array( 'datasource' => 'mysql', 'table' => 'sessions', ) ) );
In addition to the configuration variables, a table in your database must be created. The [MySQL] table schema is as follows:
CREATE TABLE sessions ( id varchar(32) COLLATE utf8_unicode_ci NOT NULL, session text COLLATE utf8_unicode_ci NOT NULL, expires_at datetime NOT NULL, PRIMARY KEY (id) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci;
Note: The reason for not using a model class was to avoid a naming conflict between the Session model and the Session class itself. This will eventually be resolved when I abandon full 5.x support and migrate to 5.3+ (assuming that ever happens).
Located in /classes/Session.php (line 51)
Object | --Session
Constructor
All of our set up logic for the session in contained here. This object is initially instantiated from pickles.php and the session callbacks are established here. All variables are driven from php.ini and/or the site config. Once configured, the session is started automatically.
Destructor
Runs garbage collection and closes the session. I'm not sure if the garbage collection should stay as it could be accomplished via php.ini variables. The session_write_close() is present to combat a chicken and egg scenario in earlier versions of PHP 5.
Closes the Session
Same as above, but in reverse.
Destroys the Session
Deletes the session from the database.
Garbage Collector
This is who you call when you got trash to be taken out.
Initializes the Session
This method exists to combat the fact that calling session_destroy() also clears out the save handler. Upon destorying a session this method is called again so the save handler is all set.
Opens the Session
Since the session is in the database, opens the database connection. This step isn't really necessary as the Database object is smart enough to open itself up upon execute.
Reads the Session
Checks the database for the session ID and returns the session data.
Writes the Session
When there's changes to the session, writes the data to the database.
Documentation generated on Wed, 03 Oct 2012 17:46:06 -0400 by phpDocumentor 1.4.4