DatabaseHandler
extends BaseHandler
in package
Base database session handler
Do not use this class. Use database specific handler class.
Table of Contents
Properties
- $cookieDomain : string
- Cookie domain
- $cookieName : string
- Cookie name to use
- $cookiePath : string
- Cookie path
- $cookiePrefix : string
- Cookie prefix
- $cookieSecure : bool
- Cookie secure?
- $db : BaseConnection
- The DB Connection instance.
- $DBGroup : string
- The database group to use for storage.
- $fingerprint : string
- The Data fingerprint.
- $idPrefix : string
- ID prefix for multiple session cookies
- $ipAddress : string
- User's IP address.
- $lock : bool|string
- Lock placeholder.
- $matchIP : bool
- Match IP addresses for cookies?
- $platform : string
- The database type
- $rowExists : bool
- Row exists flag
- $savePath : array<string|int, mixed>|string
- The 'save path' for the session varies between
- $sessionID : string|null
- Current session ID
- $table : string
- The name of the table to store session info.
Methods
- __construct() : mixed
- close() : bool
- Closes the current session.
- destroy() : bool
- Destroys a session
- gc() : false|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.
- write() : bool
- Writes the session data to the session storage.
- decodeData() : false|string
- Decodes column data
- 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.
- lockSession() : bool
- A dummy method allowing drivers with no locking functionality (databases other than PostgreSQL and MySQL) to act as if they do acquire a lock.
- prepareData() : string
- Prepare data to insert/update
- releaseLock() : bool
- Releases the lock, if any.
- setSelect() : mixed
- Sets SELECT clause
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
= ''
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
$db
The DB Connection instance.
protected
BaseConnection
$db
$DBGroup
The database group to use for storage.
protected
string
$DBGroup
$fingerprint
The Data fingerprint.
protected
string
$fingerprint
$idPrefix
ID prefix for multiple session cookies
protected
string
$idPrefix
$ipAddress
User's IP address.
protected
string
$ipAddress
$lock
Lock placeholder.
protected
bool|string
$lock
= false
$matchIP
Match IP addresses for cookies?
protected
bool
$matchIP
= false
$platform
The database type
protected
string
$platform
$rowExists
Row exists flag
protected
bool
$rowExists
= false
$savePath
The 'save path' for the session varies between
protected
array<string|int, mixed>|string
$savePath
$sessionID
Current session ID
protected
string|null
$sessionID
$table
The name of the table to store session info.
protected
string
$table
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) : false|int
Parameters
- $max_lifetime : int
-
Sessions that have not updated for the last max_lifetime seconds will be removed.
Attributes
- #[ReturnTypeWillChange]
Return values
false|int —Returns the number of deleted sessions on success, or false on failure.
open()
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
Attributes
- #[ReturnTypeWillChange]
Return values
false|string —Returns an encoded string of the read data. If nothing was read, it must return false.
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
booldecodeData()
Decodes column data
protected
decodeData(string $data) : false|string
Parameters
- $data : string
Return values
false|stringdestroyCookie()
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
boollockSession()
A dummy method allowing drivers with no locking functionality (databases other than PostgreSQL and MySQL) to act as if they do acquire a lock.
protected
lockSession(string $sessionID) : bool
Parameters
- $sessionID : string
Return values
boolprepareData()
Prepare data to insert/update
protected
prepareData(string $data) : string
Parameters
- $data : string
Return values
stringreleaseLock()
Releases the lock, if any.
protected
releaseLock() : bool
Return values
boolsetSelect()
Sets SELECT clause
protected
setSelect(BaseBuilder $builder) : mixed
Parameters
- $builder : BaseBuilder