Interface SessionInterface

Summary

Fully Qualified Name: CodeIgniter\Session\SessionInterface

Description

Expected behavior of a session container used with CodeIgniter.

Methods

Name Description Defined By
destroy() Destroys the current session. SessionInterface
get() Get user data that has been set in the session. SessionInterface
getFlashKeys() Retrieve all of the keys for session data marked as flashdata. SessionInterface
getFlashdata() Retrieve one or more items of flash data from the session. SessionInterface
getTempKeys() Retrieve the keys of all session data that have been marked as temporary data. SessionInterface
getTempdata() Returns either a single piece of tempdata, or all temp data currently in the session. SessionInterface
has() Returns whether an index exists in the session array. SessionInterface
keepFlashdata() Keeps a single piece of flash data alive for one more request. SessionInterface
markAsFlashdata() Mark a session property or properties as flashdata. SessionInterface
markAsTempdata() Mark one of more pieces of data as being temporary, meaning that it has a set lifespan within the session. SessionInterface
regenerate() Regenerates the session ID. SessionInterface
remove() Remove one or more session properties. SessionInterface
removeTempdata() Removes a single piece of temporary data from the session. SessionInterface
set() Sets user data into the session. SessionInterface
setFlashdata() Sets data into the session that will only last for a single request. SessionInterface
setTempdata() Sets new data into the session, and marks it as temporary data with a set lifespan. SessionInterface
unmarkFlashdata() Unmark data in the session as flashdata. SessionInterface
unmarkTempdata() Unmarks temporary data in the session, effectively removing its lifespan and allowing it to live as long as the session does. SessionInterface

Method Details

destroy()

Destroys the current session.

Returns:

get()

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();

Parameter Name Type Description
$key string Identifier

Returns: array|null The property value(s)

getFlashKeys()

Retrieve all of the keys for session data marked as flashdata.

Returns: array The property names of all flashdata

getFlashdata()

Retrieve one or more items of flash data from the session.

If the item key is null, return all flashdata.

Parameter Name Type Description
$key string Property

Returns: array|null The requested property value, or an associative array of them

getTempKeys()

Retrieve the keys of all session data that have been marked as temporary data.

Returns: array

getTempdata()

Returns either a single piece of tempdata, or all temp data currently in the session.

Parameter Name Type Description
$key string Session

Returns: mixed Session data value or null if not found.

has()

Returns whether an index exists in the session array.

Parameter Name Type Description
$key string Identifier

Returns: bool

keepFlashdata()

Keeps a single piece of flash data alive for one more request.

Parameter Name Type Description
$key array|string Property

Returns:

markAsFlashdata()

Mark a session property or properties as flashdata.

Parameter Name Type Description
$key string|array Property

Returns: bool if any of the properties are not already set

markAsTempdata()

Mark one of more pieces of data as being temporary, meaning that it has a set lifespan within the session.

Parameter Name Type Description
$key string|array Property
$ttl int Time

Returns: bool False if any of the properties were not set

regenerate()

Regenerates the session ID.

Parameter Name Type Description
$destroy bool Should

Returns:

remove()

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.

Parameter Name Type Description
$key string|array Identifier

Returns:

removeTempdata()

Removes a single piece of temporary data from the session.

Parameter Name Type Description
$key string Session

Returns:

set()

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.

Parameter Name Type Description
$data string|array Property
$value string|array Property

Returns:

setFlashdata()

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.

Parameter Name Type Description
$data string|array Property
$value string|array Property

Returns:

setTempdata()

Sets new data into the session, and marks it as temporary data with a set lifespan.

Parameter Name Type Description
$data string|array Session
$value mixed Value
$ttl int Time-to-live

Returns:

unmarkFlashdata()

Unmark data in the session as flashdata.

Parameter Name Type Description
$key string|array Property

Returns:

unmarkTempdata()

Unmarks temporary data in the session, effectively removing its lifespan and allowing it to live as long as the session does.

Parameter Name Type Description
$key string|array Property

Returns:

Top