php - Codeigniter session set_flashdata -


i'm having trouble using set_flashdata in ci.

controller:

if($var == true) {         // action here         $this->session->set_flashdata('success', 'success');         redirect($_server['http_referer']);     } else {         $this->session->set_flashdata('fail', 'error');          redirect($_server['http_referer']);     } 

view:

<?php if (isset($_session['fail'])): ?> <p class="text-danger"><?php echo $_session['fail'] ?></p> 
<?php if (isset($_session['success'])): ?> <p class="text-success"><?php echo $_session['success'] ?></p> 

i don't see message, no matter what. tried var_dump($this->session->flashdata('success'));

how can solve issue?

any ideas?

thank you.

first make sure have initialized correctly ($this->load->library('session');) , have encryption key set in config file.

secondly, codeigniter not utilize php's native $_session, implement own. should not test if set <?php if (isset($_session['fail'])): ?>

i try :

<?php if(isset($this->session->flashdata('fail'))): ?> <p class="text-danger"><?php echo $this->session->flashdata('fail'); ?></p> 

Comments

Popular posts from this blog

cakephp - simple blog with croogo -

How to group boxplot outliers in gnuplot -

bash - Performing variable substitution in a string -