Does Zend_Registry live until next user request?
-
29-09-2019 - |
Question
Does Zend_Registry live until next user request?
I put this code in the end of index.php file in zend project:(The code inside existing zend website)
Trial code:
//end of index.php file
Bootstrap::run();
//trial for find out the life of Zend_Registry.
$registry = Zend_Registry::getInstance();
if (!isset($registry['index1'])) {
Zend_Registry::set('index1', 'value7');
echo '<h1>Zend_Registry was unset</h1>';
} else {
echo '<h1>Zend_Registry was set</h1>';
}
Results after each click to home page:
Zend_Registry was unset
Thanks
Solution
No, Zend_Registry is just for the current request. If you want data to persist between requests you'd need to store it in the session.
OTHER TIPS
Not to answer your question but it's better to write it like this I think
try{
Zend_Registry::get('index1');
echo '<h1>Zend_Registry was set</h1>';
} catch (Exception $e) {
Zend_Registry::set('index1', 'value7');
echo '<h1>Zend_Registry was unset</h1>';
}
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow