When logging in, the system will retrieve information from that account and show it through the view page, which when we want to press a button to another page to display the information on that page by removing the information on the view page. How is it written? The information here refers to the logged-in user ID.
JavaScript
x
<a href="<?php echo site_url('data/data_member/data_member($MEM_ID)') ?>"><i class="fa fa-fw fa-user-plus"></i> History user</a>
This is the controller.
JavaScript
public function data_member($MEM_ID)
{
$data = $this->member_model->data_member($MEM_ID);
$this->load->view("containner/headofadmin");
$this->load->view("containner/headerofadmin");
$this->load->view('data/data_member',$data);
}
I use Codeigniter and PHP to write it.
Advertisement
Answer
CodeIgniter has its own Session Class
(1). First, load session library in your config.php File.
JavaScript
$this->load->library('session');
(2). In your controller.php create an array to store your session data.
JavaScript
$new_data = array(
'username' => 'John',
'email' => 'john@example.com'
);
$this->session->set_userdata($new_data);
(3). retrieve from session:-
JavaScript
$username = $this->session->userdata('username');