# How to use flash() with session in cakephp 3.3

**URL:** <https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752>\
**Category:** Need Help\
**Created:** [December 18, 2016, 9:32am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752 "2016-12-18T09:32:34Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![gabrian1977](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@gabrian1977](https://discourse.cakephp.org/u/gabrian1977)\
**Post date:** [December 18, 2016, 9:32am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/1 "2016-12-18T09:32:34Z")

</div>

I’m beginner in programming, i use cakephp 3.3 version and i want to understand how to activate session and use in controller and how to send flash message like this:$this-\>session-\>flash(‘items was updated’). What line have to add to activate session and where, how to use correctly? Thanks!

---

<div class="post-metadata">

**Author:** ![markstory](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/markstory/32/182_2.png) [@markstory](https://discourse.cakephp.org/u/markstory)\
**Post date:** [December 26, 2016, 5:12am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/2 "2016-12-26T05:12:02Z")

</div>

As soon as you add a flash message or try to display a flash message, CakePHP will activate/start the session if it has not already been started.

---

<div class="post-metadata">

**Author:** ![gabrian1977](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@gabrian1977](https://discourse.cakephp.org/u/gabrian1977)\
**Post date:** [December 30, 2016, 7:32am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/3 "2016-12-30T07:32:12Z")

</div>

You say that is not necessary to activate session? How about session component?

---

<div class="post-metadata">

**Author:** ![aavrug](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/aavrug/32/178_2.png) [@aavrug](https://discourse.cakephp.org/u/aavrug)\
**Post date:** [December 30, 2016, 7:34am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/4 "2016-12-30T07:34:59Z")

</div>

In AppController `$this->loadComponent('Flash');` this is already written so you don’t have to write anything additional.

---

<div class="post-metadata">

**Author:** ![gabrian1977](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@gabrian1977](https://discourse.cakephp.org/u/gabrian1977)\
**Post date:** [December 31, 2016, 8:38am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/5 "2016-12-31T08:38:29Z")

</div>

when i use : $this-\>Flash-\>success(\_\_(’ ')); messeges appear in blue /cakephp 3 version  
$this-\>session-\>setflash(\_(" "))/this is in cakephp 2 messages appear in red  
How do the messages appear in red using sessions and flash in cakephp 3?

---

<div class="post-metadata">

**Author:** ![aavrug](https://yyz1.discourse-cdn.com/flex029/user_avatar/discourse.cakephp.org/aavrug/32/178_2.png) [@aavrug](https://discourse.cakephp.org/u/aavrug)\
**Post date:** [January 2, 2017, 3:12am UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/6 "2017-01-02T03:12:49Z")

</div>

Please follow the official doc and you will get every answer of your questions related to CakePHP. Btw red represents error or some problem so, here in CakePHP-3 you can use `$this->Flash->error(__(' '));`

---

<div class="post-metadata">

**Author:** ![gabrian1977](https://avatars.discourse-cdn.com/v4/letter/g/ecd19e/32.png) [@gabrian1977](https://discourse.cakephp.org/u/gabrian1977)\
**Post date:** [January 4, 2017, 9:23pm UTC](https://discourse.cakephp.org/t/how-to-use-flash-with-session-in-cakephp-3-3/1752/7 "2017-01-04T21:23:15Z")

</div>

Thanks man for your help!
