# Set and flush global messages

Source: https://kart.bnomei.com/docs/guides/set-and-flush-global-messages
Updated: 2025-08-08T14:10:47+00:00
Summary: Set and flush global session messages in Kirby CMS with PHP: add, display, and remove user messages using code examples for dialog popups.

## Set a global message

You can set a single message within your PHP code in the current user session. Adding new messages will overwrite any previous ones.

Code (php):  
```
kart()->message('Your message');
```

  
## Flush/Show a global message

To show and remove (aka flush) the current message a users session you can use code like this.

Code (php):  
```
<?php if ($msg = get('msg', kart()->message())) { ?>
    <dialog>
        <p><strong>Hi <?= kirby()->user()?->nameOrEmail() ?></strong>,</p>
        <p><?= strip_tags(urldecode($msg)) ?></p>
        <form method="dialog">
            <button autofocus><?= t('close') ?></button>
        </form>
    </dialog>
    <script defer>
        // otherwise the ::backdrop pseudo attribute will not work
        setTimeout(() => {
            document.querySelector('dialog').showModal();
        }, 100);
    </script>
<?php } ?>
```

  