Skip to content

SessionPersistenceInterface

Storage backend contract for SessionManager.

Implementations own how session data is serialized and where it lives (Postgres, Redis, etc.) — SessionManager only deals in plain arrays keyed by session id.

interface SessionPersistenceInterface

Implemented byFileSessionPersistence, ObjectStoreSessionPersistence, PdoSessionPersistence, PdoSessionPersistence, RedisSessionPersistence, AzureTableSessionPersistence
SourceSession/SessionPersistenceInterface.php
MethodDescription
delete(string $sid): voidRemove the session record for this id.
[`load(string $sid): array<string, mixed>null`](#load)
save(string $sid, array<string, mixed> $data): void

abstract public function delete(string $sid): void

Remove the session record for this id.

Deleting an id that is not stored is not an error. Implementations decide how loudly a backend failure is reported, but must not leave the caller believing the record is gone when it demonstrably is not.

ParameterTypeDescription
$sidstring

abstract public function load(string $sid): array<string, mixed>|null

ParameterTypeDescription
$sidstring

Returns array``<``string``, ``mixed``>``|``null — null if the session id is unknown.

abstract public function save(string $sid, array<string, mixed> $data): void

ParameterTypeDescription
$sidstring
$dataarray``<``string``, ``mixed``>