CoreSession

Filepath: phork/php/core/CoreSession.class.php

The CoreSession class dispatches to a custom session handler which allows the application to store the session data in the database or a cache. Phork comes with a SessionDatabase class in phork/sessions/database/SessionDatabase.class.php.

The session handler must implement the SessionHandler interface which can be found at phork/php/core/interfaces/SessionHandler.interface.php.

The session class is a singleton meaning there can only be one instance of it at a time.


Basic Example

CoreSession::setHandler(new SessionDatabase());
session_start();

Example (from the bootstrap)

protected function startSession() {
    if (AppConfig::get('SessionsEnabled', false)) {
        if ($strSessionHandler = AppConfig::get('SessionHandler', false)) {
            AppLoader::includeClass('php/core/', 'CoreSession');
            CoreSession::setHandler(AppLoader::newObject('php/ext/sessions/' . strtolower($strSessionHandler) . '/', 'Session' . $strSessionHandler));
        }
    }
    parent::startSession();
}