\Hazaar\Cache\Backend
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.

Tags

Since

1.0.0

Summary
Methods Properties Constants
get
has
set
No constants
Properties
$namespace
$namespace
Static
$started
$started
$timeout
$timeout
$values
$values
$weight
$weight
Methods
Static
available()
available()
clear()
clear()

Clears all values from all applications.

This equates to a full session reset.

Use this wisely as it will affect other applications using the same session.

Tags

Since

1.0.0

close()
close()
extend()
extend()
get()
get($key) : mixed
Return the value with key $key, optionally setting a default in the process.

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

$keymixed

The key name of the data field to return.

Returns

mixed
has()
has($key) : bool

Parameters

$keymixed

No description

Returns

\Hazaar\Cache\Backend\bool
init()
init($namespace)

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.

Tags

Since

1.0.0

Parameters

$namespacestring

The namespace to use for this session

load()
load($key)

Parameters

$key

No description

remove()
remove($key)

Parameters

$key

No description

set()
set($key, $value, $timeout = null)

Parameters

$key

No description

$value

No description

$timeout

No description

toArray()
toArray()