I am trying to get the input values from the view to controller and saving this value as flashdata to use it in the other controller. Now the i am able to store the value until i redirect, but as soon as it comes to redirect, it loses its value. I am not sure whats going over here.
- Do I need to see my config again? If yes, then what I need to see?
- My both the functions are rights but if I am missing anything?
Here is my code below:-
Controller.php
public function first() {
$testing = $this->input->post('fname');
$this->session->set_flashdata('fstname', $testing);
$this->session->keep_flashdata('fstname');
// echo $this->session->flashdata('fstname'); //able to get the flashdata value till here.
redirect('Home/second/'); //but when I am using this, flashdata loses its value
}
public function second() {
$data['getfname'] = $this->session->flashdata('fstname');
$this->load->view('details', $data);
}
View (details.php)
<?php echo $getfname ?>
Output
Null
config.php
$config['sess_driver'] = 'files';
$config['sess_cookie_name'] = 'ci_session';
$config['sess_expiration'] = 7200;
$config['sess_save_path'] = APPPATH . 'cache/sessions/';
$config['sess_match_ip'] = FALSE;
$config['sess_time_to_update'] = 300;
$config['sess_regenerate_destroy'] = FALSE;
autoload.php
$autoload['libraries']=array();
Additionally, I also tried using userdata() but its not showing on the second function after redirect.
Thanks for your time.