‪TYPO3CMS  ‪main
TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend Class Reference
Inheritance diagram for TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend:
TYPO3\CMS\Core\Session\Backend\SessionBackendInterface TYPO3\CMS\Core\Session\Backend\HashableSessionBackendInterface

Public Member Functions

 initialize (string $identifier, array $configuration)
 
 validateConfiguration ()
 
 hash (string $sessionId)
 
array get (string $sessionId)
 
bool remove (string $sessionId)
 
array set (string $sessionId, array $sessionData)
 
array update (string $sessionId, array $sessionData)
 
 collectGarbage (int $maximumLifetime, int $maximumAnonymousLifetime=0)
 
array getAll ()
 

Protected Member Functions

 getQueryBuilder ()
 
 getConnection ()
 

Protected Attributes

array $configuration = array( )
 
bool $hasAnonymousSessions = false
 

Detailed Description

Class DatabaseSessionBackend

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.

Definition at line 35 of file DatabaseSessionBackend.php.

Member Function Documentation

◆ collectGarbage()

TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::collectGarbage ( int  $maximumLifetime,
int  $maximumAnonymousLifetime = 0 
)

Garbage Collection

Parameters
int$maximumLifetime‪maximum lifetime of authenticated user sessions, in seconds.
int$maximumAnonymousLifetime‪maximum lifetime of non-authenticated user sessions, in seconds. If set to 0, non-authenticated sessions are ignored.

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 192 of file DatabaseSessionBackend.php.

References $GLOBALS, and TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getQueryBuilder().

◆ get()

array TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::get ( string  $sessionId)

Read session data

Returns
‪array Returns the session data
Exceptions
SessionNotFoundException

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 87 of file DatabaseSessionBackend.php.

References TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getQueryBuilder().

◆ getAll()

array TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::getAll ( )

List all sessions

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

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 215 of file DatabaseSessionBackend.php.

References TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getQueryBuilder().

◆ getConnection()

◆ getQueryBuilder()

◆ hash()

TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::hash ( string  $sessionId)

◆ initialize()

TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::initialize ( string  $identifier,
array  $configuration 
)

Initializes the session backend

Parameters
string$identifier‪Name of the session type, e.g. FE or BE

To be used only by SessionManager

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 51 of file DatabaseSessionBackend.php.

References TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\$configuration.

◆ remove()

bool TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::remove ( string  $sessionId)

Delete a session record

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

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 108 of file DatabaseSessionBackend.php.

References TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getQueryBuilder().

◆ set()

array TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::set ( string  $sessionId,
array  $sessionData 
)

Write session data. This method prevents overriding existing session data. ses_id will always be set to $sessionId and overwritten if existing in $sessionData This method updates ses_tstamp automatically

Returns
‪array The newly created session record.
Exceptions
SessionNotCreatedException

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 130 of file DatabaseSessionBackend.php.

References $GLOBALS, TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getConnection(), TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\hash(), and TYPO3\CMS\Core\Database\Connection\PARAM_LOB.

◆ update()

array TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::update ( string  $sessionId,
array  $sessionData 
)

Updates the session data. ses_id will always be set to $sessionId and overwritten if existing in $sessionData This method updates ses_tstamp automatically

Parameters
array$sessionData‪The session data to update. Data may be partial.
Returns
‪array $sessionData The newly updated session record.
Exceptions
SessionNotUpdatedException

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 162 of file DatabaseSessionBackend.php.

References $GLOBALS, TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\getConnection(), TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend\hash(), and TYPO3\CMS\Core\Database\Connection\PARAM_LOB.

◆ validateConfiguration()

TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::validateConfiguration ( )

Checks if the configuration is valid

Exceptions

Implements TYPO3\CMS\Core\Session\Backend\SessionBackendInterface.

Definition at line 63 of file DatabaseSessionBackend.php.

Member Data Documentation

◆ $configuration

array TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::$configuration = array( )
protected

◆ $hasAnonymousSessions

bool TYPO3\CMS\Core\Session\Backend\DatabaseSessionBackend::$hasAnonymousSessions = false
protected

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

Definition at line 43 of file DatabaseSessionBackend.php.