<p>To show a message </p>

<pre><code>Craft::$app-&gt;getSession()-&gt;setNotice($message);
</code></pre>

<p>To show an error</p>

<pre><code>Craft::$app-&gt;session-&gt;setError($message);
</code></pre>

<p>There is no "default" key that is always shown or something like that. You just use the function and set a message -> the next time the user visits <em>any</em> page the message is shown.</p>

CC BY-SA 3.0
2018-04-04T20:54:10.683Z
Hi Robin - that doesn't seem to work for me. I set the flash message then redirect away with '\Craft::$app->controller->redirect("/admin/entries/tvListings");' and I get no flash message.
JamesNZ
CC BY-SA 3.0
2018-04-04T20:59:29.140Z
I'm really sorry... I messed up the functions. Please see my update
Robin Schambach
CC BY-SA 3.0
2018-04-04T23:20:18.440Z
You're a gentleman and a scholar. That worked perfectly. Thanks Robin.
JamesNZ
CC BY-SA 3.0
2018-04-03T06:12:15.563Z
2018-04-04T20:59:10.040Z
2018-04-04T20:59:10.040Z
Robin Schambach
<p>I've written a plugin that imports a CSV and creates entries from that for a client. I'm wanting to redirect them to the entries listing page after (i.e. /admin/entries/tvListings) and show a flash message saying "X TV listings imported.".</p>

<p>So this is a 2 parter:</p>

<ol>
<li>How do you set flash data in Craft 3.</li>
<li>Is there a default flash key that'll show as soon as I land on the entries listing page?</li>
</ol>

<p>Thanks.</p>

<craft3>
Showing A Flash Message On Admin Entries Listing (Craft 3)
# Showing A Flash Message On Admin Entries Listing (Craft 3)

(Asked by: username_0 on 2018-04-03)

I've written a plugin that imports a CSV and creates entries from that for a client. I'm wanting to redirect them to the entries listing page after (i.e. /admin/entries/tvListings) and show a flash message saying "X TV listings imported.".

So this is a 2 parter:

1. How do you set flash data in Craft 3.
2. Is there a default flash key that'll show as soon as I land on the entries listing page?

Thanks.

**Tags:** craft3


---

## 1 answers

### Answer by username_1 on 2018-04-03. Score: 6 | Accepted answer

To show a message 
Craft::$app->getSession()->setNotice($message);

To show an error
Craft::$app->session->setError($message);

There is no "default" key that is always shown or something like that. You just use the function and set a message -> the next time the user visits any page the message is shown.

> **Comments:**
> **username_0**: Hi Robin - that doesn't seem to work for me. I set the flash message then redirect away with '\Craft::$app->controller->redirect("/admin/entries/tvListings");' and I get no flash message.  
> **username_1**: I'm really sorry... I messed up the functions. Please see my update  
> **username_0**: You're a gentleman and a scholar. That worked perfectly. Thanks Robin.  

---

