\duncan3dc\SessionsSessionTrait

Common session functionality.

Summary

Methods
Properties
Constants
getSet()
delete()
clear()
getFlash()
setFlash()
No public properties found
No constants found
flashKey()
No protected properties found
N/A
No private methods found
No private properties found
N/A

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

Clear all previously set values.

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

flashKey()

flashKey(string  $key) : string

Converts the passed session key into a flashed key.

Parameters

string $key

The key to convert

Returns

string