RedisHandler
extends BaseHandler
in package
Session handler using Redis for persistence
Table of Contents
- $cookieDomain : string
- Cookie domain
- $cookieName : string
- Cookie name to use
- $cookiePath : string
- Cookie path
- $cookiePrefix : string
- Cookie prefix
- $cookieSecure : bool
- Cookie secure?
- $fingerprint : string
- The Data fingerprint.
- $ipAddress : string
- User's IP address.
- $keyExists : bool
- Key exists flag
- $keyPrefix : string
- Key prefix
- $lock : mixed
- Lock placeholder.
- $lockKey : string|null
- Lock key
- $logger : LoggerInterface|null
- The logger instance.
- $matchIP : bool
- Match IP addresses for cookies?
- $redis : Redis|null
- phpRedis instance
- $savePath : string|array<string|int, mixed>
- The 'save path' for the session varies between
- $sessionExpiration : int
- Number of seconds until the session ends.
- $sessionID : string
- Current session ID
- __construct() : mixed
- Constructor
- close() : bool
- Close
- destroy() : bool
- Destroy
- gc() : bool
- Garbage Collector
- open() : bool
- Open
- read() : string
- Read
- setLogger() : mixed
- Sets a logger.
- write() : bool
- Write
- destroyCookie() : bool
- Internal method to force removal of a cookie by the client when session_destroy() is called.
- fail() : bool
- Fail
- lockSession() : bool
- Get lock
- releaseLock() : bool
- Release lock
Properties
$cookieDomain
Cookie domain
protected
string
$cookieDomain
= ''
$cookieName
Cookie name to use
protected
string
$cookieName
$cookiePath
Cookie path
protected
string
$cookiePath
= '/'
$cookiePrefix
Cookie prefix
protected
string
$cookiePrefix
= ''
$cookieSecure
Cookie secure?
protected
bool
$cookieSecure
= false
$fingerprint
The Data fingerprint.
protected
string
$fingerprint
$ipAddress
User's IP address.
protected
string
$ipAddress
$keyExists
Key exists flag
protected
bool
$keyExists
= false
$keyPrefix
Key prefix
protected
string
$keyPrefix
= 'ci_session:'
$lock
Lock placeholder.
protected
mixed
$lock
= false
$lockKey
Lock key
protected
string|null
$lockKey
$logger
The logger instance.
protected
LoggerInterface|null
$logger
$matchIP
Match IP addresses for cookies?
protected
bool
$matchIP
= false
$redis
phpRedis instance
protected
Redis|null
$redis
$savePath
The 'save path' for the session varies between
protected
string|array<string|int, mixed>
$savePath
$sessionExpiration
Number of seconds until the session ends.
protected
int
$sessionExpiration
= 7200
$sessionID
Current session ID
protected
string
$sessionID
Methods
__construct()
Constructor
public
__construct(App $config, string $ipAddress) : mixed
Parameters
- $config : App
- $ipAddress : string
Tags
Return values
mixed —close()
Close
public
close() : bool
Releases locks and closes connection.
Return values
bool —destroy()
Destroy
public
destroy(string $sessionID) : bool
Destroys the current session.
Parameters
- $sessionID : string
Return values
bool —gc()
Garbage Collector
public
gc(int $maxlifetime) : bool
Deletes expired sessions
Parameters
- $maxlifetime : int
-
Maximum lifetime of sessions
Return values
bool —open()
Open
public
open(string $savePath, string $name) : bool
Sanitizes save_path and initializes connection.
Parameters
- $savePath : string
-
Server path
- $name : string
-
Session cookie name, unused
Return values
bool —read()
Read
public
read(string $sessionID) : string
Reads session data and acquires a lock
Parameters
- $sessionID : string
-
Session ID
Return values
string —Serialized session data
setLogger()
Sets a logger.
public
setLogger(LoggerInterface $logger) : mixed
Parameters
- $logger : LoggerInterface
Return values
mixed —write()
Write
public
write(string $sessionID, string $sessionData) : bool
Writes (create / update) session data
Parameters
- $sessionID : string
-
Session ID
- $sessionData : string
-
Serialized session data
Return values
bool —destroyCookie()
Internal method to force removal of a cookie by the client when session_destroy() is called.
protected
destroyCookie() : bool
Return values
bool —fail()
Fail
protected
fail() : bool
Drivers other than the 'files' one don't (need to) use the session.save_path INI setting, but that leads to confusing error messages emitted by PHP when open() or write() fail, as the message contains session.save_path ... To work around the problem, the drivers will call this method so that the INI is set just in time for the error message to be properly generated.
Return values
bool —lockSession()
Get lock
protected
lockSession(string $sessionID) : bool
Acquires an (emulated) lock.
Parameters
- $sessionID : string
-
Session ID
Return values
bool —releaseLock()
Release lock
protected
releaseLock() : bool
Releases a previously acquired lock