Controller
flashKeyExists()
Signature
Section titled “Signature”flashKeyExists() — returns boolean
Available in: controller
Category: Flash Functions
Description
Section titled “Description”Checks if a specific key exists in the Flash.
Parameters
Section titled “Parameters”| Name | Type | Required | Default | Description |
|---|---|---|---|---|
key | string | yes | — | The key to check. |
Examples
Section titled “Examples”// 1. Check for an "error" key before reading it
if (flashKeyExists("error")) {
errorMessage = flash("error");
}
// 2. Conditionally display a success notice
if (flashKeyExists("success")) {
writeOutput(flash("success"));
}
// 3. Guard before deleting a specific flash key
if (flashKeyExists("notice")) {
flashDelete("notice");
}