21.5. Theory

Zend_Session_Core provides an internal interface to encapsulate all access to singleton $_SESSION using the typical getInstance() pattern. In general, developers should not directly access $_SESSION, when using the Zend_Session component. However, it is possible for legacy code to coexist with Zend_Session, provided the namespaces used by Zend_Session do not overlap with the keys in $_SESSION used by legacy code.

All management and manipulation of global session management occurs using static "class" methods defined in Zend_Session_Core that affect the overall behavior of sessions managed by Zend_Session related components. Most developers will not need to use these static methods.

Unlike $_SESSION, Zend_Session segregates all session data into separate namespaces, by storing data in a PHP array and storing the array in $_SESSION using the namespace as the key. Constructing an instance of Zend_Session returns a non-unique "window" to the selected namespace. Multiple "windows" are possible for the same namespace, although there is only one namespace possible for a given programmatic key (the name of the namespace). These instances serve to restrict manipulation of session state data to specific namespaces, as explicitly specified when creating an instance of Zend_Session. Zend_Session instances therefore help restrict scope by introducing a locally scoped variable (instance object) that effectively imports a specific session namespace into the local scope.