Reputation: 195
I tried store data in a session using CI in my register function.
public function register(){
$firstname = $this->input->post('firstname');
$email= $this->input->post('email');
$dev_info = array('fname'=>$firstname, 'eaddress'=>$email);
$this->session->set_userdata($dev_info);
}
and in my other function verification I want to get the session data and pass to the view
public function verification(){
$data['fname'] = $this->session->userdata('fname');
$data['eaddress'] = $this->session->userdata('eaddress');
$this->load->view('index', $data);
}
and I want to save its value in input type
in the view
<input type="hidden" id="firstname" value="<?php echo $fname?>">
<input type="hidden" id="email" value="<?php echo $eaddress?>">
but i am having a hard time saving its value in an input everytime I check using view source. Please help!
Upvotes: 1
Views: 5555
Reputation: 97
in controller create session for ur input data
$data['fname'] = $this->session->userdata('fname');
$data['eaddress'] = $this->session->userdata('eaddress');
in view retrieve the input data from the session by adding the value by set_value
<input type="hidden" id="firstname" value="<?php echo set_value('fname'); ?>">
<input type="hidden" id="email" value="<?php echo set_value('eaddress'); ?>">
Upvotes: 0
Reputation: 337
you can get session variables one by one also
$first_name = $this->session->userdata('fname');
$email_address = $this->session->userdata('eaddress');
in view you can use these variables or you can write code for view like this
<input type="hidden" id="firstname" value="<?php echo $this->session->userdata('eaddress'); ?>">
<input type="hidden" id="email" value="<?php echo $this->session->userdata('fname')?>">
Upvotes: 2