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:
- lifetime - The lifetime to use for cached data. Default: 3600.
- session - Any settings to set on the session instance.
Properties
weight
protected int $weight = 3
timeout
private int $timeout = 3600
values
private array $values
started
private bool $started
baseName
private string $baseName = '/'
Methods
available
public available(): bool
init
public init(string $namespace): void
The 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(): bool
has
public has(string $key, bool $check_empty = false): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | |
$check_empty | bool |
get
Return the value with key $key, optionally setting a default in the process.
public get(string $key): mixed
If $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 = 0): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string | |
$value | mixed | |
$timeout | int |
remove
public remove(string $key): bool
Parameters
Parameter | Type | Description |
---|---|---|
$key | string |
clear
public clear(): bool
Clears all values from all applications.
This equates to a full session reset.
extend
public extend(): void
toArray
public toArray(): void
count
public count(): int
load
private load(string $key): mixed
Parameters
Parameter | Type | Description |
---|---|---|
$key | string |
Generated by Hazaar API Doc Generator