kenjis / codeigniter-ss-twig

A Simple and Secure Twig integration for CodeIgniter 3.x and 4.x
MIT License
168 stars 46 forks source link

How to use session flashdata function #42

Closed alcanardanangelo closed 6 years ago

alcanardanangelo commented 6 years ago

Hi Kenji,

How can I use the $this->session->flashdata() in my view?

If I set the flashdata in my controller like this:

$this->session->set_flashdata('success', 'Test message');
redirect('/', 'refresh');

How can I call it on my view?

Thanks!

dzakiafif commented 6 years ago

just like this in your controller : $data['message'] = $this->session->flashdata('success'); $this->twig->display('(your-view)',$data); and then in your view : {% if message %}<div class="alert">{{ message }}</div>{% endif %}