Skip to content

PdoSessionFactory

session slot factory for PdoSessionPersistence, taking its connection from the application’s own database manager so sessions live alongside everything else rather than needing separate credentials.

Parameters: database (the connection name from databases.xml; the default connection when omitted) and table (defaults to session).

A dedicated connection is worth considering under SQLite, where session writes and application writes on one file contend for the same lock.

final class PdoSessionFactory implements SessionFactoryInterface

ImplementsSessionFactoryInterface
Since3.0.0
SourceSession/PdoSessionFactory.php
MethodDescription
createPersistence(Context $context, array $parameters): SessionPersistenceInterfaceBuilds a PdoSessionPersistence over a connection from the application’s database manager.

public function createPersistence(Context $context, array $parameters): SessionPersistenceInterface

Builds a PdoSessionPersistence over a connection from the application’s database manager.

The database parameter names the connection; omitting it takes the default one. The remaining parameters, notably table, are passed through.

ParameterTypeDescription
$contextContext
$parametersarray

Returns SessionPersistenceInterface

ThrowsWhen
StorageExceptionif no database manager is bound (core.use_database off) or the named connection is not a PDO handle.