Flash¶
The flash carries short messages across a redirect. It is stored in the session,
so it needs a session store. A controller exposes it as flash.
1 2 | |
A value written to flash survives exactly one request. It is loaded on the next
request, readable there, and then dropped, so a message shown after a redirect
does not linger.
When the flash has entries, it is exposed to views as the flash local:
1 2 | |
flash.now¶
flash.now makes a message available in the current request only, for a page
rendered without a redirect. It is readable this request but is never carried to
the next one:
1 2 | |
keep and discard¶
keep carries the current flash to another request instead of dropping it.
discard removes an entry before it is saved. Both take an optional key, or act
on the whole flash when called without one:
1 2 3 | |
Flash types¶
add-flash-types registers named flash types that read and write through a
method on the flash, alongside the usual flash<key> access:
1 2 3 4 | |
It also has an is add-flash-types trait form for the class header:
1 | |
A method call for a type that was never registered raises. Registration is global, so a type added on the base controller is available everywhere.