Zend_Session_Namespace

category Zend
package Zend_Session
copyright Copyright (c) 2005-2015 Zend Technologies USA Inc. (http://www.zend.com)
license New BSD License
inherited_from \Zend_Session_Abstract

 Methods

__construct() - Returns an instance object bound to a particular, isolated section of the session, identified by $namespace name (defaulting to 'Default').

__construct(string $namespace = 'Default', boolean $singleInstance = false) : void

The optional argument $singleInstance will prevent construction of additional instance objects acting as accessors to this $namespace.

Parameters

$namespace

string
  • programmatic name of the requested namespace

$singleInstance

boolean
  • prevent creation of additional accessor instance objects for this namespace

__get() - method to get a variable in this object's current namespace

__get(string $name) : mixed

Parameters

$name

string
  • programmatic name of a key, in a pair in the current namespace

Returns

mixed

__isset() - determine if a variable in this object's namespace is set

__isset(string $name) : boolean

Parameters

$name

string
  • programmatic name of a key, in a pair in the current namespace

Returns

boolean

__set() - method to set a variable/value in this object's namespace

__set(string $name, mixed $value) : true

Parameters

$name

string
  • programmatic name of a key, in a pair in the current namespace

$value

mixed
  • value in the pair to assign to the $name key

Exceptions

\Zend_Session_Exception

Returns

true

__unset() - unset a variable in this object's namespace.

__unset(string $name) : true

Parameters

$name

string
  • programmatic name of a key, in a pair in the current namespace

Returns

true

apply() - enables applying user-selected function, such as array_merge() to the namespace Parameters following the $callback argument are passed to the callback function.

apply(string|array $callback) 

Caveat: ignores members expiring now.

Example: $namespace->apply('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose')); $namespace->apply('count');

Parameters

$callback

stringarray
  • callback function

applySet() - enables applying user-selected function, and sets entire namespace to the result Result of $callback must be an array.

applySet(string|array $callback) 

Parameters following the $callback argument are passed to the callback function. Caveat: ignores members expiring now.

Example: $namespace->applySet('array_merge', array('tree' => 'apple', 'fruit' => 'peach'), array('flower' => 'rose'));

Parameters

$callback

stringarray
  • callback function

getIterator() - return an iteratable object for use in foreach and the like, this completes the IteratorAggregate interface

getIterator() : \ArrayObject

Returns

\ArrayObject- iteratable container of the namespace contents

Returns the namespace name

getNamespace() : string

Returns

string

isLocked() - return lock status, true if, and only if, read-only

isLocked() : boolean

Returns

boolean

lock() - mark a session/namespace as readonly

lock() : void

resetSingleInstance()

resetSingleInstance(string $namespaceName = null) : null
Static

Parameters

$namespaceName

string

Returns

null

setExpirationHops() - expire the namespace, or specific variables after a specified number of page hops

setExpirationHops(integer $hops, mixed $variables = null, boolean $hopCountOnUsageOnly = false) : void

Parameters

$hops

integer
  • how many "hops" (number of subsequent requests) before expiring

$variables

mixed
  • OPTIONAL list of variables to expire (defaults to all)

$hopCountOnUsageOnly

boolean
  • OPTIONAL if set, only count a hop/request if this namespace is used

Exceptions

\Zend_Session_Exception

setExpirationSeconds() - expire the namespace, or specific variables after a specified number of seconds

setExpirationSeconds(integer $seconds, mixed $variables = null) : void

Parameters

$seconds

integer
  • expires in this many seconds

$variables

mixed
  • OPTIONAL list of variables to expire (defaults to all)

Exceptions

\Zend_Session_Exception

unlock() - unmark a session/namespace to enable read & write

unlock() : void

unlockAll() - unmark all session/namespaces to enable read & write

unlockAll() : void
Static

unsetAll() - unset all variables in this namespace

unsetAll() : true

Returns

true

namespaceGet() - Get $name variable from $namespace, returning by reference.

_namespaceGet(string $namespace, string $name = null) : mixed
InheritedStatic

Parameters

$namespace

string

$name

string

Returns

mixed

namespaceGetAll() - Get an array containing $namespace, including expiring data.

_namespaceGetAll(string $namespace) : mixed
InheritedStatic

Parameters

$namespace

string

Returns

mixed

namespaceIsset() - check to see if a namespace or a variable within a namespace is set

_namespaceIsset(string $namespace, string $name = null) : boolean
InheritedStatic

Parameters

$namespace

string

$name

string

Returns

boolean

namespaceUnset() - unset a namespace or a variable within a namespace

_namespaceUnset(string $namespace, string $name = null) : void
InheritedStatic

Parameters

$namespace

string

$name

string

Exceptions

\Zend_Session_Exception

 Properties

 

Since expiring data is handled at startup to avoid __destruct difficulties, the data that will be expiring at end of this request is held here

$_expiringData : array

Default

array()
Static
 

Namespace - which namespace this instance of zend-session is saving-to/getting-from

$_namespace : string

Default

"Default"
 

Namespace locking mechanism

$_namespaceLocks : array

Default

array()
Static
 

Whether or not session permits reading (reading data in $_SESSION[])

$_readable : boolean

Default

false
Static
 

Single instance namespace array to ensure data security.

$_singleInstances : array

Default

array()
Static
 

Whether or not session permits writing (modification of $_SESSION[])

$_writable : boolean

Default

false
Static

 Constants

 

used as option to constructor to prevent additional instances to the same namespace

SINGLE_INSTANCE = true 
 

Error message thrown when an action requires reading session data, but current Zend_Session is not marked as readable.

_THROW_NOT_READABLE_MSG = 'Zend_Session is not marked as readable.' 
 

Error message thrown when an action requires modification, but current Zend_Session has been marked as read-only.

_THROW_NOT_WRITABLE_MSG = 'Zend_Session is currently marked as read-only.'