• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Flashdata don't show up

Hello everyone,

I am having issues with flashdata. For some reason any of them won't show up. 

I am setting it like this:

// Controller
$this->session->set_flashdata('user_registered', 'You Registered Successfully!');
redirect('/'); // redirects to the index page (login page)

// View
<?php if($msg=$this->session->flashdata('user_registered')): ?>
  <?php '<p class="alert alert-danger">'.$msg.'</p>' ?>
<?php endif; ?>
I have tried 'keep_flashdata' but doesn't seem to work.
These are the configurations:

$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = NULL;
   // $config['sess_save_path'] = sys_get_temp_dir();
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

$autoload['libraries'] = array('database', 'email', 'form_validation', 'session');

Any help is very appreciated. 
Thank You!

You need to set your session path directory, this is how I do it.

Create a new directory under your ./application directory called writable.

Then set your session save path to this.

PHP Code:
$config['sess_save_path'] = APPPATH.'writable'

This works fine for me.
What did you Try? What did you Get? What did you Expect?

Joined CodeIgniter Community 2009.  ( Skype: insitfx )

The sessions  are being saved to the folder but flashdata are still not showing up.  Confused Huh

You can set flash session message using this line
$this->session->set_flashdata('success_message', 'Csv Data Imported Succesfully');

And you can Retrieve Flash session message using this line

<div class="alert alert-success successMessage">' . $this->session->flashdata('success_message') . '</div>

and $this->load->library('session');

Also updated these lines in cofig.php file
$config['sess_driver'] = 'database';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = 'ci_sessions';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;

You forgot the echo command. Try:
PHP Code:
 <class="alert alert-danger"><?php echo $msg;?></p> 

Or with the shorthand notation:
PHP Code:
 <class="alert alert-danger"><?= $msg;?></p> 

OMG, thank you Wouter60  Smile

Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  

  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.