Core_Session_Phpredis
extends Core_Session
in package
Redis Sessions using phpredis https://github.com/phpredis/phpredis
Tags
Table of Contents
Properties
- $_config : Redis
- Redis instance
- $_cookieLifetime : int
- Cookie Lifetime, default 31536000
- $_debug : bool
- Debug
- $_domain : string
- Domain, auto-detected by default
- $_error : mixed
- Error
- $_format : string
- Pack format
- $_handler : mixed
- Handler
- $_hasSessionId : mixed
- Is the current request has sent the session ID.
- $_lockKey : mixed
- Lock Key
- $_lockTimeout : int
- Lock timeout
- $_lockToken : mixed
- Lock Token
- $_maxlifetime : int
- Session maxlifetime
- $_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
- $_started : bool
- Session has been started
- $_ttl : int
- TTL
Methods
- __construct() : mixed
- Constructor.
- close() : bool
- Close session
- cookieLifetime() : mixed
- Set Cookie Lifetime
- correctDomain() : string
- Correct domain
- debug() : mixed
- Set debug
- destroy() : bool
- Destroy Session
- domain() : mixed
- Set Domain
- flushAll() : mixed
- Delete all sessions from Redis
- getConfig() : mixed
- Get Session Config
- getDomain() : string
- Get domain
- getMaxLifeTime() : int
- Get session maxlifetime
- getName() : string
- Get session name
- hasSessionId() : bool
- The is the current request has sent the session ID.
- isAcive() : bool
- Backward compatibility, see isActive()
- isActive() : bool
- Checks if the session enabled and exists
- isStarted() : bool
- Checks if the session was started
- regenerateId() : mixed
- Regenerate session ID
- sessionClose() : bool
- The close callback works like a destructor in classes and is executed after the session write callback has been called.
- sessionDestroyer() : bool
- This callback is executed when a session is destroyed with session_destroy()
- sessionGc() : bool
- The garbage collector callback is invoked internally by PHP periodically in order to purge old session data.
- sessionMaxlifetime() : bool
- This callback is executed when a session sets maxlifetime
- sessionOpen() : bool
- The open callback works like a constructor in classes and is executed when the session is being opened.
- sessionRead() : string
- The read callback must always return a session encoded (serialized) string, or an empty string if there is no data to read.
- sessionWrite() : bool
- The write callback is called when the session needs to be saved and closed.
- setMaxLifeTime() : true
- Set session maxlifetime
- start() : bool
- Start session
- _connect() : mixed
- Connect to the Redis
- _error() : mixed
- Show error
- _getDriverName() : srting
- Get full driver name
- _getKey() : mixed
- _lock() : bool
- Lock session
- _log() : mixed
- Log
- _setSessionHandler() : mixed
- Registers session handler
- _unlock() : bool
- Unlock session
Properties
$_config
Redis instance
protected
static Redis
$_config
= \NULL
$_cookieLifetime
Cookie Lifetime, default 31536000
protected
static int
$_cookieLifetime
= 31536000
$_debug
Debug
protected
static bool
$_debug
= \FALSE
$_domain
Domain, auto-detected by default
protected
static string
$_domain
= \NULL
$_error
Error
protected
static mixed
$_error
= \NULL
$_format
Pack format
protected
string
$_format
= 'i*'
$_handler
Handler
protected
static mixed
$_handler
= \NULL
$_hasSessionId
Is the current request has sent the session ID.
protected
static mixed
$_hasSessionId
= \NULL
$_lockKey
Lock Key
protected
mixed
$_lockKey
= \NULL
$_lockTimeout
Lock timeout
protected
int
$_lockTimeout
= 10
$_lockToken
Lock Token
protected
mixed
$_lockToken
= \NULL
$_maxlifetime
Session maxlifetime
protected
static int
$_maxlifetime
= \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
$_started
Session has been started
protected
static bool
$_started
= \FALSE
$_ttl
TTL
protected
int
$_ttl
= 0
Methods
__construct()
Constructor.
public
__construct() : mixed
close()
Close session
public
static close() : bool
Return values
boolcookieLifetime()
Set Cookie Lifetime
public
static cookieLifetime(int $lifetime) : mixed
Parameters
- $lifetime : int
correctDomain()
Correct domain
public
static correctDomain(mixed $domain) : string
Parameters
- $domain : mixed
Return values
stringdebug()
Set debug
public
static debug([bool $debug = TRUE ]) : mixed
Parameters
- $debug : bool = TRUE
destroy()
Destroy Session
public
static destroy(string $id) : bool
Parameters
- $id : string
-
session ID
Return values
booldomain()
Set Domain
public
static domain(string $domain) : mixed
Parameters
- $domain : string
flushAll()
Delete all sessions from Redis
public
static flushAll() : mixed
getConfig()
Get Session Config
public
static getConfig() : mixed
Tags
getDomain()
Get domain
public
static getDomain() : string
Return values
stringgetMaxLifeTime()
Get session maxlifetime
public
static getMaxLifeTime() : int
Return values
intgetName()
Get session name
public
static getName() : string
Return values
stringhasSessionId()
The is the current request has sent the session ID.
public
static hasSessionId() : bool
Return values
boolisAcive()
Backward compatibility, see isActive()
public
static isAcive() : bool
Return values
boolisActive()
Checks if the session enabled and exists
public
static isActive() : bool
Return values
boolisStarted()
Checks if the session was started
public
static isStarted() : bool
Return values
boolregenerateId()
Regenerate session ID
public
static regenerateId([bool $delete_old_session = FALSE ]) : mixed
Parameters
- $delete_old_session : bool = FALSE
-
Whether to delete the old associated session file or not, default FALSE
sessionClose()
The close callback works like a destructor in classes and is executed after the session write callback has been called.
public
sessionClose() : bool
Return values
boolsessionDestroyer()
This callback is executed when a session is destroyed with session_destroy()
public
sessionDestroyer(string $id) : bool
Parameters
- $id : string
-
session ID
Return values
boolsessionGc()
The garbage collector callback is invoked internally by PHP periodically in order to purge old session data.
public
sessionGc(string $maxlifetime) : bool
Parameters
- $maxlifetime : string
-
max life time
Return values
boolsessionMaxlifetime()
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
boolsessionOpen()
The open callback works like a constructor in classes and is executed when the session is being opened.
public
sessionOpen(string $save_path, string $session_name) : bool
Parameters
- $save_path : string
-
save path
- $session_name : string
-
session name
Return values
boolsessionRead()
The read callback must always return a session encoded (serialized) string, or an empty string if there is no data to read.
public
sessionRead(string $id) : string
Parameters
- $id : string
-
session ID
Return values
stringsessionWrite()
The write callback is called when the session needs to be saved and closed.
public
sessionWrite(string $id, string $value) : bool
Parameters
- $id : string
-
session ID
- $value : string
-
data
Return values
boolsetMaxLifeTime()
Set session maxlifetime
public
static setMaxLifeTime(int $maxlifetime[, bool $overwrite = FALSE ]) : true
Parameters
- $maxlifetime : int
- $overwrite : bool = FALSE
-
Overwrite maximum lifetime, default FALSE
Return values
truestart()
Start session
public
static start() : bool
Return values
bool_connect()
Connect to the Redis
protected
static _connect() : mixed
_error()
Show error
protected
static _error(string $content) : mixed
Parameters
- $content : string
_getDriverName()
Get full driver name
protected
static _getDriverName(string $driver) : srting
Parameters
- $driver : string
-
driver name
Return values
srting_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_log()
Log
protected
static _log(string $actionName) : mixed
Parameters
- $actionName : string
_setSessionHandler()
Registers session handler
protected
static _setSessionHandler() : mixed
_unlock()
Unlock session
protected
_unlock(int $id) : bool
Parameters
- $id : int
-
session ID