Resource - Flashes

Flash messages are text notifications or messages that are displayed once in the application. These messages are stored into sessions for one-time display after which they are removed. Notifications are handled internally by the Notice class. However, this can also be done from the Resource Res class. This makes it easier to set up or display flash messages. The three (3) main methods of the Notice class are setFlash(), Flash() and hasFlash(). The following are ways by which the flash can be applied to web applications.

  $name = 'Foo';
  if($name == 'Foo') {
      Res::setFlash('notice', 'I found a Foo');
  if( Res::hasFlash('notice') ) {
      print Res::flash('notice');
The illustration above is a sample of how to set up flash messages. The flash message are set with a specific key name having its corresponding value using the setFlash() method. The existence of a flash (key) can also be tested by using the hasFlash() method while Res::flash() returns the value of a specified key.

Flash in Template files
When flash messages are set using the Res::setFlash() method, the flash can be imported using the flash() directive in template files to call the flash key name. The flash will only be displayed once it exists.