Session ​
- Type
- Class
- Namespace
- craft\helpers
- Inherits
- craft\helpers\Session
- Since
- 3.6.9
Class Session
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).
Returns ​
get()
​
Returns the session variable value with the session variable name.
Arguments ​
$key
(string) – The session variable name
Returns ​
mixed
– The session variable value, or null
if it doesn’t exist
has()
​
Returns whether a session variable exists.
Arguments ​
$key
(string) – The session variable name
Returns ​
boolean – Whether there is the named session variable
remove()
​
Removes a session variable.
Arguments ​
$key
(string) – The session variable name
Returns ​
mixed
– The old value, or null
if it didn’t exist
removeAll()
​
Removes all session variables.
Returns ​
void
reset()
​
- Since
- 3.5.12.1
Resets the memoized database connection.
set()
​
Adds a session variable.
If the specified name already exists, the old value will be overwritten.
Arguments ​
$key
(string) – The session variable name$value
(mixed
) – The session variable value
Returns ​
void