Suneth Senanayake Suneth Senanayake - 2 months ago 7
PHP Question

How to pass messages in codeigniter?

How to pass

error messages
and
success messages
to one function to another using
Codeigniter
?
I need to show messages in my view when that action success or fail.

Answer

two ways to do it.

01) You can use flashdata

its very simple.

$this->session->set_flashdata('give_some_useful_word', 'value');

set your message variable to value.

now you can use it any where in controller like this,

$this->session->flashdata('given_word');

02)You can use sessions

$this->session->set_userdata('give_some_useful_word', 'value');

add your message varible to value.

now you can use it any where in controller like this,

$this->session->userdata('given_word');

Both are like same coding but I recomanded 1st method.

further knowldge here

Comments