\duncan3dc\HelpersSession

Summary

Methods
Properties
Constants
name()
get()
set()
getSet()
destroy()
No public properties found
No constants found
init()
$init
$name
$data
N/A
No private methods found
No private properties found
N/A

Properties

$init

$init : boolean

Type

boolean — Whether the session has been started or not.

$name

$name : string

Type

string — The name of the session.

$data

$data : array

Type

array — The cache of the session data.

Methods

name()

name(string $name) : void

Set the name of the session to use.

Parameters

string $name

The name of the session

get()

get(string $key) : mixed

Get a value from the session data cache.

Parameters

string $key

The name of the name to retrieve

Returns

mixed

set()

set(string|array $data, mixed $value) : void

Set a value within session data.

Parameters

string|array $data

Either the name of the session key to update, or an array of keys to update

mixed $value

If $data is a string then store this value in the session data

getSet()

getSet(string $key, mixed $default) : mixed

This is a convenience method to prevent having to do several checks/set for all persistant variables.

If the key name has been passed via POST then that value is stored in the session and returned. If the key name has been passed via GET then that value is stored in the session and returned. If there is already a value in the session data then that is returned. If all else fails then the default value is returned. All checks are truthy/falsy (so a POST value of "0" is ignored).

Parameters

string $key

The name of the key to retrieve from session data

mixed $default

The value to use if the current session value is falsy

Returns

mixed

destroy()

destroy() : void

Tear down the session and wipe all it's data.

init()

init() : void

Ensure the session data is loaded into cache.