regenerate()
regenerate(boolean $destroy = false)
Regenerates the session ID.
Parameters
boolean | $destroy | Should old session data be destroyed? |
Expected behavior of a session container used with CodeIgniter.
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. |
setFlashdata(string|array $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.
string|array | $data | Property identifier or associative array of properties |
string|array | $value | Property value if $data is a scalar |
setTempdata(string|array $data, mixed $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 |
mixed | $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