Skip to content

Flashing messages

Dylan Anderson edited this page Jun 24, 2020 · 2 revisions

Messages can be flashed to enable them to be saved in the session and retrieved on subsequent page loads. This may be useful if you're POSTing a form to a different URL, then redirecting afterwards. Flashing enables messages generated from saving, to be shown to the user after the redirect.

Storing

Feedback::flash() can be called to store the messages currently stored in Feedback, in the session. Any messages already stored are overwritten. The session must be started before calling this method, or an exception is thrown.

Messages are stored in the session under the Feedback::$session_key key.

Retrieving

Feedback::setToFlashed() can be used to retrieve messages from the session. Any messages stored in Feedback before setToFlashed() is called, get overwritten.

By default, once the messages are retrieved from the session, they get removed. You can keep the messages in session by passing TRUE to setToFlashed()