Skip to content

Session ​

Type
Class
Namespace
craft\helpers
Inherits
craft\helpers\Session
Since
3.6.9

Class Session

View source

Public Methods ​

MethodDescription
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

Returns ​

boolean

get() ​

Returns the session variable value with the session variable name.

View source

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.

View source

Arguments ​

  • $key (string) – The session variable name

Returns ​

boolean – Whether there is the named session variable

remove() ​

Removes a session variable.

View source

Arguments ​

  • $key (string) – The session variable name

Returns ​

mixed – The old value, or null if it didn’t exist

removeAll() ​

Removes all session variables.

View source

Returns ​

void

reset() ​

Since
3.5.12.1

Resets the memoized database connection.

View source

set() ​

Adds a session variable.

If the specified name already exists, the old value will be overwritten.

View source

Arguments ​

  • $key (string) – The session variable name
  • $value (mixed) – The session variable value

Returns ​

void