Welcome Guest, Not a member yet? Register   Sign In
Flashdata don't show up
#1

Hello everyone,

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

I am setting it like this:

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

Code:
// 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!
Reply
#2

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 )
Reply
#3

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

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;
Reply
#5

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> 
Reply
#6

OMG, thank you Wouter60  Smile
Reply




Theme © iAndrew 2016 - Forum software by © MyBB