Back

flash()

The flash() function is used in controllers to access data stored in the Flash scope. Flash is a temporary storage mechanism that lets you persist values across the next request (often after a redirect). You can use it to retrieve a specific key or the entire Flash struct. If you pass in a key, it returns the value associated with it; if no key is passed, it returns all the Flash contents as a struct.

Name Type Required Default Description
key string No The key to get the value for.
1. Get a specific Flash value (commonly used for notifications or messages)

notice = flash("notice");

2. Get another value stored in Flash, e.g., an error message

errorMsg = flash("error");

3. Retrieve the entire Flash scope as a struct

allFlash = flash();
Copied!