Session storage container

Allows for interacting with session storage in isolated containers, which may have their own expiries, or even expiries per key in the container. Additionally, expiries may be absolute TTLs or measured in "hops", which are based on how many times the key or container were accessed.

category Zend
package Zend_Session

 Methods

Constructor

__construct(null | string $name, \Zend\Session\ManagerInterface $manager) 

Provide a name ('Default' if none provided) and a ManagerInterface instance.

Parameters

$name

nullstring

Exceptions

\Zend\Session\Exception\InvalidArgumentException

append()

append() 

inherited_from ArrayObject::append()

asort()

asort() 

inherited_from ArrayObject::asort()

count()

count() 

inherited_from ArrayObject::count()

Exchange the current array with another array or object.

exchangeArray(array | object $input) : array

see \ArrayObject::exchangeArray()

Parameters

$input

arrayobject

Returns

arrayReturns the old array

getArrayCopy()

getArrayCopy() 

inherited_from ArrayObject::getArrayCopy()

Get the default ManagerInterface instance

getDefaultManager() : \Zend\Session\ManagerInterface

If none provided, instantiates one of type $managerDefaultClass

Exceptions

\Zend\Session\Exception\InvalidArgumentException if invalid manager default class provided

Returns

getFlags()

getFlags() 

inherited_from ArrayObject::getFlags()

Iterate over session container

getIterator() : \Iterator

Returns

\Iterator

getIteratorClass()

getIteratorClass() 

inherited_from ArrayObject::getIteratorClass()

Get manager instance

getManager() : \Zend\Session\ManagerInterface

Get container name

getName() : string

Returns

string

ksort()

ksort() 

inherited_from ArrayObject::ksort()

natcasesort()

natcasesort() 

inherited_from ArrayObject::natcasesort()

natsort()

natsort() 

inherited_from ArrayObject::natsort()

Determine if the key exists

offsetExists(string $key) : bool

Parameters

$key

string

Returns

bool

Retrieve a specific key in the container

offsetGet(string $key) : mixed

Parameters

$key

string

Returns

mixed

Store a value within the container

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

Parameters

$key

string

$value

mixed

Unset a single key in the container

offsetUnset(string $key) : void

Parameters

$key

string

serialize()

serialize() 

inherited_from ArrayObject::serialize()

Set the default ManagerInterface instance to use when none provided to constructor

setDefaultManager(\Zend\Session\ManagerInterface $manager) : void

Parameters

Set expiration hops for the container, a single key, or set of keys

setExpirationHops(int $hops, null | string | array $vars) : \Zend\Session\Container

Parameters

$hops

int

$vars

nullstringarray

Exceptions

\Zend\Session\Exception\InvalidArgumentException

Returns

Set expiration TTL

setExpirationSeconds(int $ttl, string | array | null $vars) : \Zend\Session\Container

Set the TTL for the entire container, a single key, or a set of keys.

Parameters

$ttl

int

TTL in seconds

$vars

stringarraynull

Exceptions

\Zend\Session\Exception\InvalidArgumentException

Returns

setFlags()

setFlags() 

inherited_from ArrayObject::setFlags()

setIteratorClass()

setIteratorClass() 

inherited_from ArrayObject::setIteratorClass()

uasort()

uasort() 

inherited_from ArrayObject::uasort()

uksort()

uksort() 

inherited_from ArrayObject::uksort()

unserialize()

unserialize() 

inherited_from ArrayObject::unserialize()

Create a new container object on which to act

createContainer() : \ArrayObject

Returns

Expire a key by expiry time

expireByExpiryTime(\Zend\Session\Storage\StorageInterface $storage, string $name, string $key) : bool

Checks to see if the entire container has expired based on TTL setting, or the individual key.

Parameters

$name

string

Container name

$key

string

Key in container to check

Returns

bool

Expire key by session hops

expireByHops(\Zend\Session\Storage\StorageInterface $storage, string $name, string $key) : bool

Determines whether the container or an individual key within it has expired based on session hops

Parameters

$name

string

$key

string

Returns

bool

Determine whether a given key needs to be expired

expireKeys(null | string $key) : bool

Returns true if the key has expired, false otherwise.

Parameters

$key

nullstring

Returns

bool

Get session storage object

getStorage() : \Zend\Session\Storage\StorageInterface

Proxies to ManagerInterface::getStorage()

Returns

Set session manager

setManager(\Zend\Session\ManagerInterface $manager) : \Zend\Session\Container

Verify container namespace

verifyNamespace(bool $createContainer) : \Zend\Session\Storage\StorageInterface | null

Checks to see if a container exists within the Storage object already. If not, one is created; if so, checks to see if it's an ArrayObject. If not, it raises an exception; otherwise, it returns the Storage object.

Parameters

$createContainer

bool

Whether or not to create the container for the namespace

Exceptions

\Zend\Session\Exception\RuntimeException

Returns

\Zend\Session\Storage\StorageInterfacenullReturns null only if $createContainer is false

 Properties

 

Default manager to use when instantiating a container without providing a ManagerInterface

$defaultManager : \Zend\Session\ManagerInterface

 

$manager

$manager : \Zend\Session\ManagerInterface

 

Default manager class to use if no manager has been provided

$managerDefaultClass : string

 

Container name

$name : string