Session storage in $_SESSION

Replaces the $_SESSION superglobal with an ArrayObject that allows for property access, metadata storage, locking, and immutability.

package Default
inherited_from \Zend\Session\Storage\ArrayStorage

 Methods

Constructor

__construct(array|null $input = null, integer $flags = \Zend\Stdlib\ArrayObject::ARRAY_AS_PROPS, string $iteratorClass = '\\ArrayIterator'

Sets the $_SESSION superglobal to an ArrayObject, maintaining previous values if any discovered.

inherited_from \Zend\Session\Storage\ArrayStorage::__construct()

Parameters

$input

arraynull

$flags

integer

$iteratorClass

string

Constructor

__construct(array $input = array(), integer $flags = self::STD_PROP_LIST, string $iteratorClass = 'ArrayIterator'
Inherited

Parameters

$input

array

$flags

integer

$iteratorClass

string

Destructor

__destruct() : void

Resets $_SESSION superglobal to an array, by casting object using getArrayCopy().

Returns the value at the specified key by reference

__get(mixed $key) : mixed
Inherited

Parameters

$key

mixed

Returns

mixed

Returns whether the requested key exists

__isset(mixed $key) : boolean
Inherited

Parameters

$key

mixed

Returns

boolean

Sets the value at the specified key to value

__set(mixed $key, mixed $value) : void
Inherited

Parameters

$key

mixed

$value

mixed

Unsets the value at the specified key

__unset(mixed $key) : void
Inherited

Parameters

$key

mixed

Appends the value

append(mixed $value) : void
Inherited

Parameters

$value

mixed

Sort the entries by value

asort() : void
Inherited

Clear the storage object or a subkey of the object

clear(null|integer|string $key = null) : \Zend\Session\Storage\ArrayStorage
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::clear()

Parameters

$key

nullintegerstring

Exceptions

\Zend\Session\Exception\RuntimeException

Returns

\Zend\Session\Storage\ArrayStorage

Get the number of public properties in the ArrayObject

count() : integer
Inherited

Returns

integer

Exchange the array for another one.

exchangeArray(array|\Zend\Stdlib\ArrayObject $data) : array
Inherited

Parameters

$data

array\Zend\Stdlib\ArrayObject

Returns

array

Load session object from an existing array

fromArray(array $array) : \Zend\Session\Storage\SessionStorage

Ensures $_SESSION is set to an instance of the object when complete.

inherited_from \Zend\Session\Storage\ArrayStorage::fromArray()

Parameters

$array

array

Returns

\Zend\Session\Storage\SessionStorage

Load the storage from another array

fromArray(array $array) : \Zend\Session\Storage\ArrayStorage
Inherited

Overwrites any data that was previously set.

inherited_from \Zend\Session\Storage\StorageInterface::fromArray()

Parameters

$array

array

Returns

\Zend\Session\Storage\ArrayStorage

Creates a copy of the ArrayObject.

getArrayCopy() : array
Inherited

Returns

array

Gets the behavior flags.

getFlags() : integer
Inherited

Returns

integer

Create a new iterator from an ArrayObject instance

getIterator() : \Iterator
Inherited

Returns

\Iterator

Gets the iterator classname for the ArrayObject.

getIteratorClass() : string
Inherited

Returns

string

Retrieve the request access time

getRequestAccessTime() : float
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::getRequestAccessTime()

Returns

float

Determine if this object is isImmutable

isImmutable() : boolean
inherited_from \Zend\Session\Storage\ArrayStorage::isImmutable()

Returns

boolean

Is the storage container marked as isImmutable?

isImmutable() : boolean
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::isImmutable()

Returns

boolean

Is the object or key marked as locked?

isLocked(null|integer|string $key = null) : boolean
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::isLocked()

Parameters

$key

nullintegerstring

Returns

boolean

Sort the entries by key

ksort() : void
Inherited

Lock this storage instance, or a key within it

lock(null|integer|string $key = null) : \Zend\Session\Storage\ArrayStorage
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::lock()

Parameters

$key

nullintegerstring

Returns

\Zend\Session\Storage\ArrayStorage

Mark object as isImmutable

markImmutable() : \Zend\Session\Storage\SessionStorage
inherited_from \Zend\Session\Storage\ArrayStorage::markImmutable()

Returns

\Zend\Session\Storage\SessionStorage

Mark the storage container as isImmutable

markImmutable() : \Zend\Session\Storage\ArrayStorage
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::markImmutable()

Returns

\Zend\Session\Storage\ArrayStorage

Sort an array using a case insensitive "natural order" algorithm

natcasesort() : void
Inherited

Sort entries using a "natural order" algorithm

natsort() : void
Inherited

Returns whether the requested key exists

offsetExists(mixed $key) : boolean
Inherited

Parameters

$key

mixed

Returns

boolean

Returns the value at the specified key

offsetGet(mixed $key) : mixed
Inherited

Parameters

$key

mixed

Returns

mixed

Sets the value at the specified key to value

offsetSet(mixed $key, mixed $value) : void
Inherited

Parameters

$key

mixed

$value

mixed

Unsets the value at the specified key

offsetUnset(mixed $key) : void
Inherited

Parameters

$key

mixed

Serialize an ArrayObject

serialize() : string
Inherited

Returns

string

Sets the behavior flags

setFlags(integer $flags) : void
Inherited

Parameters

$flags

integer

Sets the iterator classname for the ArrayObject

setIteratorClass(string $class) : void
Inherited

Parameters

$class

string

Cast the object to an array

toArray(boolean $metaData = false) : array
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::toArray()

Parameters

$metaData

boolean

Whether to include metadata

Returns

array

Sort the entries with a user-defined comparison function and maintain key association

uasort(callable $function) : void
Inherited

Parameters

$function

callable

Sort the entries by keys using a user-defined comparison function

uksort(callable $function) : void
Inherited

Parameters

$function

callable

Unlock an object or key marked as locked

unlock(null|integer|string $key = null) : \Zend\Session\Storage\ArrayStorage
Inherited
inherited_from \Zend\Session\Storage\StorageInterface::unlock()

Parameters

$key

nullintegerstring

Returns

\Zend\Session\Storage\ArrayStorage

Unserialize an ArrayObject

unserialize(string $data) : void
Inherited

Parameters

$data

string

Set the request access time

setRequestAccessTime(float $time) : \Zend\Session\Storage\ArrayStorage
Inherited

Parameters

$time

float

Returns

\Zend\Session\Storage\ArrayStorage

 Properties

 

$flag

$flag : integer

Default

 

Is storage marked isImmutable?

$isImmutable : boolean

Default

false
 

$iteratorClass

$iteratorClass : string

Default

 

$protectedProperties

$protectedProperties : array

Default

 

$storage

$storage : array

Default

 Constants

 

Entries can be accessed as properties (read and write).

ARRAY_AS_PROPS = 2 
 

Properties of the object have their normal functionality when accessed as list (var_dump, foreach, etc.).

STD_PROP_LIST = 1