Sessions
in package
This class is responsible for handling all session related operations
Tags
Table of Contents
Methods
- configure() : bool
- Set the session cookie parameters
- destroy() : bool
- Destroys all data registered to a session
- get() : mixed
- Gets and returns a certain value from the session
- has() : bool
- Checks if a certain key is already in the session
- regerateKey() : bool
- Update the current session id with a newly generated one
- remove() : bool
- Destroys a specific key in the session
- set() : array<string|int, mixed>
- Sets the given key to the given value into the session and returns the current entire session values
- start() : bool
- Initialize session data
Methods
configure()
Set the session cookie parameters
public
static configure([array<string|int, mixed>|null $lifetime_or_option = [] ]) : bool
Parameters
- $lifetime_or_option : array<string|int, mixed>|null = []
-
– An associative array which may have any of the keys lifetime, path, domain, secure, httponly and samesite. The values have the same meaning as described for the parameters with the same name. The value of the samesite element should be either Lax or Strict. If any of the allowed options are not given, their default values are the same as the default values of the explicit parameters. If the samesite element is omitted, no SameSite cookie attribute is set
Return values
booldestroy()
Destroys all data registered to a session
public
static destroy() : bool
Return values
bool —true on success or false on failure.
get()
Gets and returns a certain value from the session
public
static get( $key) : mixed
Parameters
has()
Checks if a certain key is already in the session
public
static has( $key) : bool
Parameters
Return values
boolregerateKey()
Update the current session id with a newly generated one
public
static regerateKey([bool|null $should_delete_old_session = true ]) : bool
Parameters
- $should_delete_old_session : bool|null = true
Return values
boolremove()
Destroys a specific key in the session
public
static remove( $key) : bool
Parameters
Return values
boolset()
Sets the given key to the given value into the session and returns the current entire session values
public
static set( $key, $value) : array<string|int, mixed>
Parameters
Return values
array<string|int, mixed>start()
Initialize session data
public
static start([array<string|int, mixed>|null $options = [] ]) : bool
Parameters
- $options : array<string|int, mixed>|null = []
-
– [optional] If provided, this is an associative array of options that will override the currently set session configuration directives. The keys should not include the session. prefix. In addition to the normal set of configuration directives,va read_and_close option may also be provided. If set to TRUE,this will result in the session being closed immediately after being read, thereby avoiding unnecessary locking if the session data won't be changed.