Documentation

Core_Session_Phpredis
in package
implements SessionHandlerInterface

Redis Sessions using phpredis https://github.com/phpredis/phpredis

Tags
subpackage

Core

version
7.x
copyright

© 2005-2025, https://www.hostcms.ru

Table of Contents

Interfaces

SessionHandlerInterface

Properties

$_config  : Redis
Redis instance
$_format  : string
Pack format
$_lockKey  : mixed
Lock Key
$_lockTimeout  : int
Lock timeout
$_lockToken  : mixed
Lock Token
$_nextStepDelay  : int
Next step delay (microseconds) Default 0,5 sec - 500000 microseconds
$_prefix  : string
Lock prefix
$_read  : bool
Session has been read
$_redis  : Redis
Redis instance
$_ttl  : int
TTL

Methods

__construct()  : mixed
Constructor.
close()  : bool
The close callback works like a destructor in classes and is executed after the session write callback has been called.
create_sid()  : string
This callback is executed when a new session ID is required.
destroy()  : bool
This callback is executed when a session is destroyed with session_destroy()
flushAll()  : mixed
Delete all sessions from Redis
gc()  : bool
The garbage collector callback is invoked internally by PHP periodically in order to purge old session data.
open()  : bool
The open callback works like a constructor in classes and is executed when the session is being opened.
read()  : string
The read callback must always return a session encoded (serialized) string, or an empty string if there is no data to read.
sessionMaxlifetime()  : bool
This callback is executed when a session sets maxlifetime
validateId()  : bool
This callback is executed when a session is to be started, a session ID is supplied and session.use_strict_mode is enabled
write()  : bool
The write callback is called when the session needs to be saved and closed.
_connect()  : mixed
Connect to the Redis
_getKey()  : mixed
_lock()  : bool
Lock session
_unlock()  : bool
Unlock session

Properties

$_config

Redis instance

protected static Redis $_config = \NULL

$_format

Pack format

protected string $_format = 'i*'

$_lockKey

Lock Key

protected mixed $_lockKey = \NULL

$_lockTimeout

Lock timeout

protected int $_lockTimeout = 10

$_lockToken

Lock Token

protected mixed $_lockToken = \NULL

$_nextStepDelay

Next step delay (microseconds) Default 0,5 sec - 500000 microseconds

protected int $_nextStepDelay = 500000

$_prefix

Lock prefix

protected string $_prefix = \NULL

$_read

Session has been read

protected bool $_read = \FALSE

$_redis

Redis instance

protected static Redis $_redis = \NULL

Methods

__construct()

Constructor.

public __construct() : mixed

close()

The close callback works like a destructor in classes and is executed after the session write callback has been called.

public close() : bool
Return values
bool

create_sid()

This callback is executed when a new session ID is required.

public create_sid() : string
Return values
string

destroy()

This callback is executed when a session is destroyed with session_destroy()

public destroy(string $id) : bool
Parameters
$id : string

session ID

Return values
bool

flushAll()

Delete all sessions from Redis

public static flushAll() : mixed

gc()

The garbage collector callback is invoked internally by PHP periodically in order to purge old session data.

public gc(string $maxlifetime) : bool
Parameters
$maxlifetime : string

max life time

Return values
bool

open()

The open callback works like a constructor in classes and is executed when the session is being opened.

public open(string $save_path, string $session_name) : bool
Parameters
$save_path : string

save path

$session_name : string

session name

Return values
bool

read()

The read callback must always return a session encoded (serialized) string, or an empty string if there is no data to read.

public read(string $id) : string
Parameters
$id : string

session ID

Return values
string

sessionMaxlifetime()

This callback is executed when a session sets maxlifetime

public sessionMaxlifetime(int $maxlifetime[, bool $overwrite = FALSE ]) : bool
Parameters
$maxlifetime : int
$overwrite : bool = FALSE

overwrite previous maxlifetime

Return values
bool

validateId()

This callback is executed when a session is to be started, a session ID is supplied and session.use_strict_mode is enabled

public validateId(string $id) : bool
Parameters
$id : string

Session ID

Return values
bool

write()

The write callback is called when the session needs to be saved and closed.

public write(string $id, string $value) : bool
Parameters
$id : string

session ID

$value : string

data

Return values
bool

_connect()

Connect to the Redis

protected static _connect() : mixed

_getKey()

protected _getKey(mixed $id) : mixed
Parameters
$id : mixed

_lock()

Lock session

protected _lock(int $id) : bool
Parameters
$id : int

session ID

Return values
bool

_unlock()

Unlock session

protected _unlock(int $id) : bool
Parameters
$id : int

session ID

Return values
bool

        
On this page

Search results