Search code examples
phpzend-frameworkzend-framework-mvc

Does Zend_Registry live until next user request?


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.