$logger
$logger : \PSR\Log\LoggerInterface
Logger instance to record error messages and warnings.
Implementation of CodeIgniter session container.
Session configuration is done through session variables and cookie related variables in app/config/App.php
$driver : \CodeIgniter\Log\Handlers\HandlerInterface
Instance of the driver to use.
$sessionSavePath : string
The location to save sessions to, driver dependent.
.
For the 'files' driver, it's a path to a writable directory. WARNING: Only absolute paths are supported!
For the 'database' driver, it's a table name.
TODO: address memcache & redis needs
IMPORTANT: You are REQUIRED to set a valid save path!
setLogger(\Psr\Log\LoggerInterface $logger)
Sets a logger.
\Psr\Log\LoggerInterface | $logger |
__construct(\SessionHandlerInterface $driver, \Config\App $config)
Constructor.
Extract configuration settings and save them here.
\SessionHandlerInterface | $driver | |
\Config\App | $config |
set(string|array $data, string|array $value = null)
Sets user data into the session.
If $data is a string, then it is interpreted as a session property key, and $value is expected to be non-null.
If $data is an array, it is expected to be an array of key/value pairs to be set as session properties.
string|array | $data | Property name or associative array of properties |
string|array | $value | Property value if single key provided |
get(string $key = null) : array|null
Get user data that has been set in the session.
If the property exists as "normal", returns it. Otherwise, returns an array of any temp or flash data values with the property key.
Replaces the legacy method $session->userdata();
string | $key | Identifier of the session property to retrieve |
The property value(s)
remove(string|array $key)
Remove one or more session properties.
If $key is an array, it is interpreted as an array of string property identifiers to remove. Otherwise, it is interpreted as the identifier of a specific session property to remove.
string|array | $key | Identifier of the session property or properties to remove. |
__isset(string $key) : boolean
Magic method to check for session variables.
Different from has() in that it will validate 'session_id' as well. Mostly used by internal PHP functions, users should stick to has()
string | $key | Identifier of the session property to remove. |
setFlashdata(array|string $data, string|array $value = null)
Sets data into the session that will only last for a single request.
Perfect for use with single-use status update messages.
If $data is an array, it is interpreted as an associative array of key/value pairs for flashdata properties. Otherwise, it is interpreted as the identifier of a specific flashdata property, with $value containing the property value.
array|string | $data | Property identifier or associative array of properties |
string|array | $value | Property value if $data is a scalar |
setTempdata(string|array $data, null $value = null, integer $ttl = 300)
Sets new data into the session, and marks it as temporary data with a set lifespan.
string|array | $data | Session data key or associative array of items |
null | $value | Value to store |
integer | $ttl | Time-to-live in seconds |
markAsTempdata(string|array $key, integer $ttl = 300) : boolean
Mark one of more pieces of data as being temporary, meaning that it has a set lifespan within the session.
string|array | $key | Property identifier or array of them |
integer | $ttl | Time to live, in seconds |
False if any of the properties were not set
configureSidLength() : void
Configure session ID length
To make life easier, we used to force SHA-1 and 4 bits per character on everyone. And of course, someone was unhappy.
Then PHP 7.1 broke backwards-compatibility because ext/session is such a mess that nobody wants to touch it with a pole stick, and the one guy who does, nobody has the energy to argue with.
So we were forced to make changes, and OF COURSE something was going to break and now we have this pile of shit. -- Narf