\Anax\SessionSessionConfigurable

Class for wrapping sessions.

Summary

Methods
Properties
Constants
configure()
getConfig()
name()
start()
has()
get()
getOnce()
set()
delete()
destroy()
__debugInfo()
No public properties found
No constants found
No protected methods found
$config
N/A
No private methods found
No private properties found
N/A

Properties

$config

$config : array<mixed,>

Type

array<mixed,> — store the configuration in this array.

Methods

configure()

configure(array|string  $what) : self

Read configuration from file or array, if a file, first check in ANAX_APP_PATH/config and then in ANAX_INSTALL_PATH/config.

Parameters

array|string $what

is an array with key/value config options or a file to be included which returns such an array.

Throws

\Anax\Configure\Exception

when argument if not a file nor an array.

Returns

self —

for chaining.

getConfig()

getConfig(string  $key, string  $default = null) : mixed

Helper function for reading values from the configuration and appy default values where configuration item is missing.

Parameters

string $key

matching a key in the config array.

string $default

value returned when config item is not found.

Returns

mixed —

or null if key does not exists.

name()

name(array  $name = null) : self

Set a session name from argument or from configuration.

Parameters

array $name

to set as session name.

Returns

self

start()

start() : self

Start the session (ignore when on cli).

Returns

self

has()

has(string  $key) : boolean

Check if a value is set in the session.

Parameters

string $key

in session variable.

Returns

boolean —

true if $key is set, else false.

get()

get(string  $key, mixed  $default = null) : mixed

Get a value from the session.

Parameters

string $key

in session variable.

mixed $default

default value to return when key is not set in the session.

Returns

mixed —

value from session and null if not set.

getOnce()

getOnce(string  $key, mixed  $default = null) : mixed

Read a value from the session and unset it, this is a form of read once flash memory using the session.

Parameters

string $key

in session variable.

mixed $default

default value to return when key is not set in the session.

Returns

mixed —

value from session and null if not set.

set()

set(string  $key, mixed  $value) : self

Set values in session.

Parameters

string $key

in session variable.

mixed $value

to set in session.

Returns

self

delete()

delete(string  $key) : self

Unset session value of this key.

Parameters

string $key

in session variable.

Returns

self

destroy()

destroy() : void

Destroy the session (works even on cli).

__debugInfo()

__debugInfo() : array

To enable var_dump() of the session object.

Returns

array