\duncan3dc\SessionsSessionNamespace

A namespaced portion of the session data.

Summary

Methods
Properties
Constants
getSet()
delete()
clear()
getFlash()
setFlash()
__construct()
createNamespace()
get()
getAll()
set()
No public properties found
No constants found
flashKey()
getNamespace()
getNamespacedKey()
$name
$session
N/A
No private methods found
No private properties found
N/A

Properties

$name

$name : string

Type

string — The namespace of the session.

Methods

getSet()

getSet(string  $key, mixed  $default = null, boolean  $strict = false) : 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), unless the 3rd parameter is set to true.

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

boolean $strict

Whether to do strict comparisons or not

Returns

mixed

delete()

delete(  $keys) : static

Unset a value within session data.

Parameters

$keys

Returns

static

clear()

clear() : static

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

Returns

static

getFlash()

getFlash(string  $key) : mixed

Retrieve a one-time value from the session data.

Parameters

string $key

The name of the flash value to retrieve

Returns

mixed

setFlash()

setFlash(string  $key, mixed  $value) : static

Set a one-time value within session data.

Parameters

string $key

The name of the flash value to update

mixed $value

The value to store against the key

Returns

static

__construct()

__construct(string  $name, \duncan3dc\Sessions\SessionInstance  $session) 

Create a new namespaced portion of a session.

Parameters

string $name

The namespace of the session

\duncan3dc\Sessions\SessionInstance $session

The session instance to use

createNamespace()

createNamespace(string  $name) : \duncan3dc\Sessions\SessionNamespace

Create a new namespaced section of this session to avoid clashes.

Parameters

string $name

The namespace of the session

Returns

\duncan3dc\Sessions\SessionNamespace

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

getAll()

getAll() : array

Get all the current session data.

Returns

array

set()

set(string|array  $data, mixed  $value = null) : static

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

Returns

static

flashKey()

flashKey(string  $key) : string

Converts the passed session key into a flashed key.

Parameters

string $key

The key to convert

Returns

string

getNamespace()

getNamespace() : string

Get the namespace prefix for keys.

Returns

string

getNamespacedKey()

getNamespacedKey(string  $key) : string

Converts the passed session key into a namespaced key.

Parameters

string $key

The key to convert

Returns

string