Back
flashInsert()
The flashInsert() function adds a new key-value pair to the Flash scope. This is useful for storing temporary messages or data that you want to persist across the next request, typically after a redirect. You can insert any type of value, such as strings, numbers, or structs, and later retrieve it using flash().
1. Insert a simple flash message
flashInsert(msg="It Worked!");
2. Insert multiple types of data
flashInsert(userId=123);
flashInsert(errorMessage="Something went wrong");
3. Typical usage: insert a message before redirecting
flashInsert(notice="Profile updated successfully");
redirectTo(action="show");
4. Insert a structured value
flashInsert(userStruct={id=42, name="Alice"});
Copied!