MemcachedHandler
extends BaseHandler
in package
uses
PersistsConnection
Session handler using Memcached for persistence.
Table of Contents
Properties
- $connectionPool : array<string, object>
- Connection pool keyed by connection identifier.
- $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.
- $keyPrefix : string
- Key prefix.
- $lock : bool|string
- Lock placeholder.
- $lockKey : string|null
- Lock key
- $matchIP : bool
- Match IP addresses for cookies?
- $memcached : Memcached|null
- Memcached instance.
- $savePath : array<string, mixed>|string
- The 'save path' for the session varies between.
- $sessionExpiration : int
- Number of seconds until the session ends.
- $sessionID : string|null
- Current session ID.
Methods
- __construct() : mixed
- close() : bool
- Closes the current session.
- destroy() : bool
- Destroys a session.
- gc() : int
- Cleans up expired sessions.
- open() : bool
- Re-initialize existing session, or creates a new one.
- read() : false|string
- Reads the session data from the session storage, and returns the results.
- resetPersistentConnections() : void
- Reset all persistent connections (useful for testing).
- write() : bool
- Writes the session data to the session storage.
- destroyCookie() : bool
- Internal method to force removal of a cookie by the client when session_destroy() is called.
- 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.
- getConnectionIdentifier() : string
- Get connection identifier based on configuration.
- getPersistentConnection() : object|null
- Get the persistent connection for this configuration.
- hasPersistentConnection() : bool
- Check if a persistent connection exists for this configuration.
- lockSession() : bool
- Acquires an emulated lock.
- releaseLock() : bool
- Releases a previously acquired lock.
- setPersistentConnection() : void
- Store a connection for persistence.
Properties
$connectionPool
Connection pool keyed by connection identifier.
protected
static array<string, object>
$connectionPool
= []
Allows multiple configurations to each have their own connection.
$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
= ''
The Config\Cookie::$prefix setting is completely ignored. See https://codeigniter.com/user_guide/libraries/sessions.html#session-preferences
$cookieSecure
Cookie secure?
protected
bool
$cookieSecure
= false
$fingerprint
The Data fingerprint.
protected
string
$fingerprint
$ipAddress
User's IP address.
protected
string
$ipAddress
$keyPrefix
Key prefix.
protected
string
$keyPrefix
= 'ci_session:'
$lock
Lock placeholder.
protected
bool|string
$lock
= false
$lockKey
Lock key
protected
string|null
$lockKey
$matchIP
Match IP addresses for cookies?
protected
bool
$matchIP
= false
$memcached
Memcached instance.
protected
Memcached|null
$memcached
$savePath
The 'save path' for the session varies between.
protected
array<string, mixed>|string
$savePath
$sessionExpiration
Number of seconds until the session ends.
protected
int
$sessionExpiration
= 7200
$sessionID
Current session ID.
protected
string|null
$sessionID
Methods
__construct()
public
__construct(Session $config, string $ipAddress) : mixed
Parameters
- $config : Session
- $ipAddress : string
Tags
close()
Closes the current session.
public
close() : bool
Return values
booldestroy()
Destroys a session.
public
destroy(string $id) : bool
Parameters
- $id : string
-
The session ID being destroyed.
Return values
boolgc()
Cleans up expired sessions.
public
gc(int $max_lifetime) : int
Parameters
- $max_lifetime : int
-
Sessions that have not updated for the last max_lifetime seconds will be removed.
Return values
intopen()
Re-initialize existing session, or creates a new one.
public
open(string $path, string $name) : bool
Parameters
- $path : string
-
The path where to store/retrieve the session.
- $name : string
-
The session name.
Return values
boolread()
Reads the session data from the session storage, and returns the results.
public
read(string $id) : false|string
Parameters
- $id : string
-
The session ID.
Return values
false|stringresetPersistentConnections()
Reset all persistent connections (useful for testing).
public
static resetPersistentConnections() : void
write()
Writes the session data to the session storage.
public
write(string $id, string $data) : bool
Parameters
- $id : string
-
The session ID.
- $data : string
-
The encoded session data.
Return values
booldestroyCookie()
Internal method to force removal of a cookie by the client when session_destroy() is called.
protected
destroyCookie() : bool
Return values
boolfail()
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.
protected
fail() : bool
Return values
boolgetConnectionIdentifier()
Get connection identifier based on configuration.
protected
getConnectionIdentifier() : string
This returns a unique hash for each distinct connection configuration.
Return values
stringgetPersistentConnection()
Get the persistent connection for this configuration.
protected
getPersistentConnection() : object|null
Return values
object|nullhasPersistentConnection()
Check if a persistent connection exists for this configuration.
protected
hasPersistentConnection() : bool
Return values
boollockSession()
Acquires an emulated lock.
protected
lockSession(string $sessionID) : bool
Parameters
- $sessionID : string
-
Session ID.
Return values
boolreleaseLock()
Releases a previously acquired lock.
protected
releaseLock() : bool
Return values
boolsetPersistentConnection()
Store a connection for persistence.
protected
setPersistentConnection(object|null $connection) : void
Parameters
- $connection : object|null
-
The connection to persist (null to clear).