# FlashMessenger

## Introduction

The FlashMessenger helper allows you to pass messages that the user may need to see on the next request. To accomplish this, FlashMessenger uses `Zend_Session_Namespace` to store messages for future or next request retrieval. It is generally a good idea that if you plan on using `Zend_Session` or `Zend_Session_Namespace`, that you initialize with `Zend_Session::start()` in your bootstrap file. (See the Zend_Session documentation for more details on its usage.)

## Basic Usage Example

The usage example below shows the use of the flash messenger at its most basic. When the action `/some/my` is called, it adds the flash message "Record Saved!" A subsequent request to the action `/some/my-next-request` will retrieve it (and thus delete it as well).

    class SomeController extends Zend_Controller_Action
    {
        /**
         * FlashMessenger
         *
         * @var Zend_Controller_Action_Helper_FlashMessenger
         */
        protected $_flashMessenger = null;

        public function init()
        {
            $this->_flashMessenger =
                $this->_helper->getHelper('FlashMessenger');
            $this->initView();
        }

        public function myAction()
        {
            /**
             * default method of getting
             * Zend_Controller_Action_Helper_FlashMessenger instance
             * on-demand
             */
            $this->_flashMessenger->addMessage('Record Saved!');
        }

        public function myNextRequestAction()
        {
            $this->view->messages = $this->_flashMessenger->getMessages();
            $this->render();
        }
    }