Session
Session
Session cache backend class
The session cache backend class allows access to a PHP session using standard class access methods. It will automatically start a session if one is not already started. Sessions can be namespaced to prevent variable collisions.
Available config options:
- ttl - The time-to-live value to use for cached data. Default: 3600.
- session - Any settings to set on the session instance.
Properties
weight
protected int $weight = 3timeout
private int $timeout = 3600values
private array $valuesstarted
private bool $startedbaseName
private string $baseName = '/'Methods
available
public available(): boolinit
public init(string $namespace): voidThe session backend init method is responsible for maintaining a valid session. If a session has not already been started it will configure and start one automatically. You can specify a namespace for the session. The constructor will also maintain any timeouts for values as per the application configuration.
Parameters
| Parameter | Type | Description |
|---|---|---|
$namespace | string | The namespace to use for this session |
close
public close(): boolhas
public has(string $key, bool $checkEmpty): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$checkEmpty | bool |
get
Return the value with key $key, optionally setting a default in the process.
public get(string $key): mixedIf $default is supplied and no value for $key is currently set in the session then the default value will be set in the session and then returned.
Parameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
set
public set(string $key, mixed $value, int $timeout): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string | |
$value | mixed | |
$timeout | int |
remove
public remove(string $key): boolParameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
clear
public clear(): boolClears all values from all applications.
This equates to a full session reset.
extend
public extend(): voidtoArray
public toArray(): voidcount
public count(): intload
private load(string $key): mixedParameters
| Parameter | Type | Description |
|---|---|---|
$key | string |
Generated by Hazaar API Doc Generator on Mon, 27 Oct 2025 13:01:29 +0000