Skip to content

Controller

flashKeyExists()

flashKeyExists() — returns boolean

Available in: controller Category: Flash Functions

The flashKeyExists() function checks whether a specific key is present in the Flash scope. It returns true if the key exists and false if it does not. This is useful for conditionally displaying or processing Flash messages or data before attempting to read them.

NameTypeRequiredDefaultDescription
keystringyesThe key to check.
1. Check if the "error" key exists
errorExists = flashKeyExists("error");

2. Conditional display based on key existence
if (flashKeyExists("notice")) {
    writeOutput(flash("notice"));
}

3. Example usage in a form flow
if (flashKeyExists("validationErrors")) {
    errors = flash("validationErrors");
    // Process or display errors
}