Back
flashDelete()
The flashDelete() function removes a specific key from the Flash scope. It is useful when you want to delete a particular temporary message or piece of data without clearing the entire Flash. The function returns true if the key existed and was deleted, or false if the key was not present.
1. Delete a single flash message
flashDelete(key="errorMessage");
2. Delete another key and check if it existed
if (flashDelete(key="notice")) {
writeOutput("Notice deleted from Flash.");
} else {
writeOutput("Notice key did not exist.");
}
3. Conditional usage before displaying flash
if (structKeyExists(flash(), "warning")) {
warningMsg = flash("warning");
flashDelete(key="warning"); // remove after reading
writeOutput(warningMsg);
}
Copied!