DatabaseSessionBackend

class \TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend

Implements
SessionBackendInterface, HashableSessionBackendInterface

This session backend requires the 'table' configuration option. If the backend is used to holds non-authenticated sessions (default in frontend application), the 'ses_userid' configuration option must be set to `0`.

Table of Contents

Interfaces

SessionBackendInterface
Interface SessionBackendInterface
HashableSessionBackendInterface

Properties

$configuration  : array
$hasAnonymousSessions  : bool

Methods

collectGarbage()  : mixed
Garbage Collection
get()  : array
Read session data
getAll()  : array
List all sessions
hash()  : string
initialize()  : mixed
Initializes the session backend
remove()  : bool
Delete a session record
set()  : array
Write session data. This method prevents overriding existing session data.
update()  : array
Updates the session data.
validateConfiguration()  : bool
Checks if the configuration is valid
getConnection()  : Connection
getQueryBuilder()  : QueryBuilder

Properties

$configuration

protected array $configuration = []

$hasAnonymousSessions

protected bool $hasAnonymousSessions = false

Indicates whether the ses_userid is set to 0 in the sessions table

Methods

collectGarbage()

Garbage Collection

public collectGarbage(int $maximumLifetime[, int $maximumAnonymousLifetime = 0 ]) : mixed

Parameters

$maximumLifetime : int

maximum lifetime of authenticated user sessions, in seconds.

$maximumAnonymousLifetime : int = 0

maximum lifetime of non-authenticated user sessions, in seconds. If set to 0, non-authenticated sessions are ignored.

get()

Read session data

public get(string $sessionId) : array

Parameters

$sessionId : string

Tags

throws
SessionNotFoundException

Return values

array —

Returns the session data

getAll()

List all sessions

public getAll() : array

Return values

array —

Return a list of all user sessions. The list may be empty

hash()

public hash(string $sessionId) : string

Parameters

$sessionId : string

Return values

string

initialize()

Initializes the session backend

public initialize(string $identifier, array $configuration) : mixed

Parameters

$identifier : string

Name of the session type, e.g. FE or BE

$configuration : array

remove()

Delete a session record

public remove(string $sessionId) : bool

Parameters

$sessionId : string

Return values

bool —

true if the session was deleted, false it session could not be found

set()

Write session data. This method prevents overriding existing session data.

public set(string $sessionId, array $sessionData) : array

ses_id will always be set to $sessionId and overwritten if existing in $sessionData This method updates ses_tstamp automatically

Parameters

$sessionId : string
$sessionData : array

Tags

throws
SessionNotCreatedException

Return values

array —

The newly created session record.

update()

Updates the session data.

public update(string $sessionId, array $sessionData) : array

ses_id will always be set to $sessionId and overwritten if existing in $sessionData This method updates ses_tstamp automatically

Parameters

$sessionId : string
$sessionData : array

The session data to update. Data may be partial.

Tags

throws
SessionNotUpdatedException

Return values

array —

$sessionData The newly updated session record.

validateConfiguration()

Checks if the configuration is valid

public validateConfiguration() : bool

Tags

throws
InvalidArgumentException

Return values

bool
On this page