Zend Framework 101: Zend_Session
Creating Session Namespaces
The Zend Framework provides advanced session handling using the Zend_Session component. Using this component, you no longer need to access PHP's $_SESSION global variable.
$_SESSION at all when using Zend_Session.Zend_Session uses namespaces to store your session data. That is, when you want to read or write session data you must first specify a namespace. This allows you to easily store different session data without worrying too much about other values stored in the session.
You create a new session namespace by instantiating the Zend_Session_Namespace class. The first argument to the constructor is the name of the namespace. Listing 1 shows an example of this.
require_once('Zend/Session.php'); $session = new Zend_Session_Namespace('identity');
We can now read or write session data in the identity namespace using the $session variable. I will show you how to do this shortly.
Note also that you do not need to manually start sessions (using the session_start() function) as you might have in the past when using sessions in PHP. Instantiating this class takes care of this for you.
Zend_Session::start() instead.Internally, the above code will be accessing data in the $_SESSION['identity'] variable. You should never access this directly.






