Session
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\Session
- Since
- 3.6.9
Class Session
View source (opens new window)
# Public Methods
Method | Description |
---|---|
exists() | Returns whether a PHP session exists (regardless of whether it’s currently active). |
get() | Returns the session variable value with the session variable name. |
has() | Returns whether a session variable exists. |
remove() | Removes a session variable. |
removeAll() | Removes all session variables. |
reset() | Resets the memoized database connection. |
set() | Adds a session variable. |
# exists()
Returns whether a PHP session exists (regardless of whether it’s currently active).
View source (opens new window)
Returns
# get()
Returns the session variable value with the session variable name.
View source (opens new window)
Arguments
$key
(string (opens new window)) – The session variable name
Returns
mixed
– The session variable value, or null
if it doesn’t exist
# has()
Returns whether a session variable exists.
View source (opens new window)
Arguments
$key
(string (opens new window)) – The session variable name
Returns
boolean (opens new window) – Whether there is the named session variable
# remove()
Removes a session variable.
View source (opens new window)
Arguments
$key
(string (opens new window)) – The session variable name
Returns
mixed
– The old value, or null
if it didn’t exist
# removeAll()
Removes all session variables.
View source (opens new window)
# reset()
- Since
- 3.5.12.1
Resets the memoized database connection.
View source (opens new window)
# set()
Adds a session variable.
If the specified name already exists, the old value will be overwritten.
View source (opens new window)
Arguments
$key
(string (opens new window)) – The session variable name$value
(mixed
) – The session variable value
← Sequence StringHelper →