Flash Messaging Overview

Heads Up! Flash messages require sessions. If you do not use the \Yee\Middleware\SessionCookie middleware, you must start a native PHP session by yourself.

Yee supports flash messaging much like Rails and other larger web frameworks. Flash messaging allows you to define messages that persist until the next HTTP request but no further. This is helpful to display messages to the user after a given event or error occurs.

As shown below, the Yee application’s flash() and flashNow() methods accept two arguments: a key and a message. The key may be whatever you want and defines how the message will be accessed in the view templates. For example, if we invoke the Yee application’s flash('foo', 'The foo message') method with those arguments, you can access that message in the next request’s templates with flash['foo'].

Flash messages are persisted with sessions; sessions are required for flash messages to work. Flash messages are stored in $_SESSION['yee.flash'].