How to show message on view in codeigniter?
Open application/config/config.php
and edit the line:
$config['encryption_key'] = '';
by adding some random values to the string
$config['encryption_key'] = 'q0231sz!!1@asd';
After that, when you've set the message with
$this->session->set_flashdata('key', 'value');
in your view file simply echo
echo $this->session->flashdata('key');
Note, that this will not echo your 'value'
on this load, but will echo it after you refresh the page
$this->session->set_flashdata('mykey', 'testing');echo $this->session->flashdata('mykey'); // will echo '' (nothing)
The solution to your error is pointed out in your question:
In order to use the Session class you are required to set an encryption key in your config file.
You can set controller to,
$this->data['errormsg'] = "message";
then set view to
echo isset($errormsg)?$errormsg:"" ;