Navig: Blog > Zend Framework
Post 9: Managing application.ini and session data in Zend Framework
Posted on February 09, 12 @ 07:05 am under Zend Framework. A. Accessing application.ini data
There will be times when configuration items are needed in the logic. There is a way you can access it.
This line can be given in init() of the controller.
$this->_config = $this->getInvokeArg('bootstrap')->getOptions();
Now the config data is available as array for controllers.
_____________________________________________________________________________________
B. Accessing session data.
Session data is available as class members by instantiating session namespace.
For easiness,
1. the session namespace can be specified in the application.ini. and can be called in the code.
2. as an alternate, instead of calling many times, in init(), you can instantiate a class member variable, which will be available for the controller.
$this->_session = new Zend_Session_Namespace($this->_config['sessionName']);
_____________________________________________________________________________________
C. Making session data available for view.
In init() of controller, you can add following line, after the above line.
$this->view->sessionData=$this->_session;
 Comments
No comments. |