Back

flashKeyExists()

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.

Name Type Required Default Description
key string Yes The 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
}
Copied!