\Disco\classesSession

Convient wrapper around using $_SESSION variables.

Summary

Methods
Properties
Constants
__construct()
__destruct()
has()
in()
total()
keys()
set()
setComplex()
get()
getComplex()
remove()
regen()
reset()
flush()
destroy()
setFlash()
getFlash()
hasFlash()
flash()
setComplexFlash()
getComplexFlash()
No public properties found
FLASH_KEY
No protected methods found
No protected properties found
N/A
No private methods found
$newFlash
$flash
N/A

Constants

FLASH_KEY

FLASH_KEY

Properties

$newFlash

$newFlash : array

Type

array — Flash data set during current request.

$flash

$flash : array

Type

array — Flash data from previous request.

Methods

__construct()

__construct() 

Start up our session by calling `session_start()` and set the flash data if necessary.

__destruct()

__destruct() 

Set the current flash if necessary.

has()

has(string  $k) : boolean

Does a session variable exist?

Parameters

string $k

The session to check.

Returns

boolean

in()

in(string|array  $k) : boolean

Does the session have a value for the key(s)?

Parameters

string|array $k

The key(s) to check for in the session.

Returns

boolean —

Whether the key is in the session.

total()

total() : integer

The total number of keys in the session.

Returns

integer —

The total number of session variables.

keys()

keys() : array

Get all keys being used to store session variables.

Returns

array —

The keys.

set()

set(string  $k, \Disco\classes\numeric|string  $v) : void

Set a SESSION variable.

Parameters

string $k

The key to set the SESSION variable with.

\Disco\classes\numeric|string $v

The value of the $k.

setComplex()

setComplex(string  $k, mixed  $v) : void

Set a complex SESSION variable, performing serialize on the value passed, allowing for arrays, objects, and any complex data type to be stored in the session.

Parameters

string $k

The key to set the SESSION variable with.

mixed $v

The complex data type to store.

get()

get(string  $k) : false|mixed

Get a SESSION variable.

Parameters

string $k

The SESSION variable to get.

Returns

false|mixed

getComplex()

getComplex(string  $k) : mixed

Get a complex SESSION variable, deserializing it before it is returned.

Parameters

string $k

The complex SESSION variable to get.

Returns

mixed

remove()

remove(string  $k) : void

Delete a SESSION variable.

Parameters

string $k

The SESSION to remove

regen()

regen() : void

Regenerate a SESSION id and keep the data.

reset()

reset() : void

Reset a SESSION.

flush()

flush() : void

Clear all SESSION variables.

destroy()

destroy() : void

Destroy A SESSION.

setFlash()

setFlash(string  $key, mixed  $value) 

Set a piece of flash data.

Parameters

string $key

The flash data key.

mixed $value

The flash data value.

getFlash()

getFlash(string  $key) : false|mixed

Get a piece of flash data.

Parameters

string $key

The flash data key.

Returns

false|mixed —

False if not set.

hasFlash()

hasFlash(string  $key) : boolean

Whether a flash session variable is set.

Parameters

string $key

The flash data key.

Returns

boolean

flash()

flash() : array

Get the current flash data.

Returns

array

setComplexFlash()

setComplexFlash(string  $key, mixed  $value) 

Set a piece of complex flash data.

Parameters

string $key

The flash data key.

mixed $value

The flash data value.

getComplexFlash()

getComplexFlash(string  $key) : false|mixed

Get a piece of flash data.

Parameters

string $key

The flash data key.

Returns

false|mixed —

False if not set.