RedisSessionBackend implements SessionBackendInterface, HashableSessionBackendInterface, LoggerAwareInterface uses LoggerAwareTrait

Class RedisSessionBackend

This session backend takes these optional configuration options: 'hostname' (default '127.0.0.1'), 'database' (default 0), 'port' (default 3679) and 'password' (no default value).

Table of Contents

Interfaces

SessionBackendInterface
Interface SessionBackendInterface
HashableSessionBackendInterface
LoggerAwareInterface

Properties

$applicationIdentifier  : string
Used as instance independent identifier (e.g. if multiple installations write into the same database)
$configuration  : array<string|int, mixed>
$connected  : bool
Indicates whether the server is connected
$identifier  : string
$redis  : Redis
Instance of the PHP redis class

Methods

collectGarbage()  : mixed
Garbage Collection
get()  : array<string|int, mixed>
Read session data
getAll()  : array<string|int, mixed>
List all sessions
hash()  : string
initialize()  : mixed
Initializes the session backend
remove()  : bool
Delete a session record
set()  : array<string|int, mixed>
Write session data. This method prevents overriding existing session data.
update()  : array<string|int, mixed>
Updates the session data.
validateConfiguration()  : mixed
Checks if the configuration is valid
getSessionKeyName()  : string
getSessionTimeout()  : int
initializeConnection()  : mixed
Initializes the redis backend

Properties

$applicationIdentifier

Used as instance independent identifier (e.g. if multiple installations write into the same database)

protected string $applicationIdentifier = ''

$configuration

protected array<string|int, mixed> $configuration = []

$connected

Indicates whether the server is connected

protected bool $connected = false

$redis

Instance of the PHP redis class

protected Redis $redis

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, nothing is collected.

get()

Read session data

public get(string $sessionId) : array<string|int, mixed>
Parameters
$sessionId : string
Tags
throws
SessionNotFoundException
Return values
array<string|int, mixed>

Returns the session data

getAll()

List all sessions

public getAll() : array<string|int, mixed>
Return values
array<string|int, mixed>

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<string|int, mixed> $configuration) : mixed
Parameters
$identifier : string

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

$configuration : array<string|int, mixed>
Internal

To be used only by SessionManager

remove()

Delete a session record

public remove(string $sessionId) : bool
Parameters
$sessionId : string
Return values
bool

set()

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

public set(string $sessionId, array<string|int, mixed> $sessionData) : array<string|int, mixed>

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<string|int, mixed>
Tags
throws
SessionNotCreatedException
Return values
array<string|int, mixed>

The newly created session record.

update()

Updates the session data.

public update(string $sessionId, array<string|int, mixed> $sessionData) : array<string|int, mixed>

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<string|int, mixed>

The session data to update. Data may be partial.

Tags
throws
SessionNotUpdatedException
Return values
array<string|int, mixed>

$sessionData The newly updated session record.

validateConfiguration()

Checks if the configuration is valid

public validateConfiguration() : mixed
Internal

To be used only by SessionManager

Tags
throws
InvalidArgumentException

getSessionKeyName()

protected getSessionKeyName(string $sessionId) : string
Parameters
$sessionId : string
Return values
string

getSessionTimeout()

protected getSessionTimeout() : int
Return values
int

initializeConnection()

Initializes the redis backend

protected initializeConnection() : mixed
Tags
throws
RuntimeException

if access to redis with password is denied or if database selection fails


        
On this page

Search results