Flash messages
A page that takes a post redirects the browser to a plain page, so a refresh cannot post twice - and then the page the browser lands on has to say what happened. A flash message carries that: padFlash ( 'Thanks, your message was sent.' ) before the padRedirect (), and {flash} on the page it leads to.
|
PHP fragments/flash_messages_1.php |
HTML fragments/flash_messages_1.pad |
Result |
|---|---|---|
|
|
Your message was sent. |
-
{flash} renders its content once per message, with
{$message}and{$type}; without a message the @else@ half renders.{flash 'error'}shows the messages of that type only. - The type is the second argument of
padFlash,infowhen it is left out. - A message lives exactly one request after the one that flashed it - the redirect's destination - and is gone after that, shown or not. A page that flashes and renders itself shows it at once, as here.
- The message is kept in the session, which starts on demand. A small
padFlashcookie tells the next request that there is something to take, so the pages that never flash do not open the session at all.