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.
<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.
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.
$this->load->library('session');
(2). In your controller.php create an array to store your session data.
$new_data = array( 'username' => 'John', 'email' => 'john@example.com' ); $this->session->set_userdata($new_data);
(3). retrieve from session:-
$username = $this->session->userdata('username');