src/Http/Session/Registry/Storage/PdoSessionRegistryStorage.php
public function createTable()
    {
        // connect if we are not yet
        $this->getConnection();

        switch ($this->driver) {
            case 'mysql':
                // We use varbinary for the ID column because it prevents unwanted conversions:
                // - character set conversions between server and client
                // - trailing space removal
                // - case-insensitivity
                // - language processing like é == e
                $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB";
                break;
            case 'sqlite':
                $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'pgsql':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'oci':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'sqlsrv':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            default:
                throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
        }

        try {
            $this->getConnection()->exec($sql);
        } catch (\PDOException $e) {
            throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e);
        }
    }
public function createTable()
    {
        // connect if we are not yet
        $this->getConnection();

        switch ($this->driver) {
            case 'mysql':
                // We use varbinary for the ID column because it prevents unwanted conversions:
                // - character set conversions between server and client
                // - trailing space removal
                // - case-insensitivity
                // - language processing like é == e
                $sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB";
                break;
            case 'sqlite':
                $sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'pgsql':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'oci':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            case 'sqlsrv':
                $sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)";
                break;
            default:
                throw new \DomainException(sprintf('Creating the session table is currently not implemented for PDO driver "%s".', $this->driver));
        }

        try {
            $this->getConnection()->exec($sql);
        } catch (\PDOException $e) {
            throw new \RuntimeException(sprintf('PDOException was thrown when trying to create sessions info table: %s', $e->getMessage()), 0, $e);
        }
    }
public function createTable ( ) { // connect if we are not yet $ this -> getConnection ( ) ; switch ( $ this -> driver ) { case 'mysql' : // We use varbinary for the ID column because it prevents unwanted conversions: // - character set conversions between server and client // - trailing space removal // - case-insensitivity // - language processing like é == e $ sql = "CREATE TABLE $this->table ($this->idCol VARBINARY(128) NOT NULL PRIMARY KEY, $this->usernameCol VARBINARY(256) NOT NULL, $this->lastUsedCol INTEGER UNSIGNED NOT NULL, $this->expiredCol INTEGER UNSIGNED) COLLATE utf8_bin, ENGINE = InnoDB" ; break ; case 'sqlite' : $ sql = "CREATE TABLE $this->table ($this->idCol TEXT NOT NULL PRIMARY KEY, $this->usernameCol TEXT NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'pgsql' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'oci' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR2(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; case 'sqlsrv' : $ sql = "CREATE TABLE $this->table ($this->idCol VARCHAR(128) NOT NULL PRIMARY KEY, $this->usernameCol VARCHAR(256) NOT NULL, $this->lastUsedCol INTEGER NOT NULL, $this->expiredCol INTEGER)" ; break ; default : throw new \ DomainException ( sprintf ( 'Creating the session table is currently not implemented for PDO driver "%s".' , $ this -> driver ) ) ; } try { $ this -> getConnection ( ) -> exec ( $ sql ) ; } catch ( \ PDOException $ e ) { throw new \ RuntimeException ( sprintf ( 'PDOException was thrown when trying to create sessions info table: %s' , $ e -> getMessage ( ) ) , 0 , $ e ) ; } }
Creates the table to store sessions which can be called once for setup.

Session ID is saved in a column of maximum length 128 because that is enough even
for a 512 bit configured session.hash_function like Whirlpool. Session username is
saved in a varchar of maximun length 256 because any valid email should fit into it.
One could also use a larger column if one was sure the data dfits into it.

@throws \RuntimeException When the table cannot be created
@throws \DomainException  When an unsupported PDO driver is used
Creates the table to store sessions which can be called once for setup .