DB\SQL\Session::__construct PHP Method

__construct() public method

Instantiate class
public __construct ( SQL $db, $table = 'sessions', $force = TRUE, $onsuspect = NULL, $key = NULL )
$db DB\SQL \DB\SQL
$table string
$force bool
$onsuspect callback
$key string
    function __construct(\DB\SQL $db, $table = 'sessions', $force = TRUE, $onsuspect = NULL, $key = NULL)
    {
        if ($force) {
            $eol = "\n";
            $tab = "\t";
            $db->exec((preg_match('/mssql|sqlsrv|sybase/', $db->driver()) ? 'IF NOT EXISTS (SELECT * FROM sysobjects WHERE ' . 'name=' . $db->quote($table) . ' AND xtype=\'U\') ' . 'CREATE TABLE dbo.' : 'CREATE TABLE IF NOT EXISTS ' . (($name = $db->name()) && $db->driver() != 'pgsql' ? $db->quotekey($name, FALSE) . '.' : '')) . $db->quotekey($table, FALSE) . ' (' . $eol . $tab . $db->quotekey('session_id') . ' VARCHAR(255),' . $eol . $tab . $db->quotekey('data') . ' TEXT,' . $eol . $tab . $db->quotekey('ip') . ' VARCHAR(45),' . $eol . $tab . $db->quotekey('agent') . ' VARCHAR(300),' . $eol . $tab . $db->quotekey('stamp') . ' INTEGER,' . $eol . $tab . 'PRIMARY KEY (' . $db->quotekey('session_id') . ')' . $eol . ');');
        }
        parent::__construct($db, $table);
        $this->onsuspect = $onsuspect;
        session_set_save_handler([$this, 'open'], [$this, 'close'], [$this, 'read'], [$this, 'write'], [$this, 'destroy'], [$this, 'cleanup']);
        register_shutdown_function('session_commit');
        $fw = \Base::instance();
        $headers = $fw->get('HEADERS');
        $this->_csrf = $fw->get('SEED') . '.' . $fw->hash(mt_rand());
        if ($key) {
            $fw->set($key, $this->_csrf);
        }
        $this->_agent = isset($headers['User-Agent']) ? $headers['User-Agent'] : '';
        $this->_ip = $fw->get('IP');
    }