pass variable to every controller Using the Registry in Zend Framework
Can I use zend Registry to 开发者_如何学运维save variable to use in other controller? this is my code that don't work in another controller:
Zend_Registry::set('id', $Id);
Zend_Registry
is an alternative to the old school $GLOBALS
. It's a container, you put stuff in there, and will retrieve them later on.
Where do you put id
in registry? In the Bootstrap
? init
? Make sure it's called in your application flow.
Maybe you expect zend_registry to work like a cookie witch it does'nt. If you set something in a controller then click some link to another controller you will have lost that data. Otherwise like shadowfax said just make sure you set your data somewhere in the application flow.
精彩评论