When a customer selects a navigation system, you need to save the navigation selection for customers in the database.
Use login.
Retrieve data from the database.
I display client information like this in the controller.
...
if(isset($_SESSION['customer_id'])){
$data['fname'] = $_SESSION['customer_first_name'];
$data['lname'] = $_SESSION['customer_last_name'];
$data['telephone'] = $_SESSION['phone_number'];
$data['email'] = $_SESSION['email'];
$data['address'] = $_SESSION['address'];
$data['city'] = $_SESSION['city'];
$data['pcode'] = $_SESSION['post_code'];
}
$this->load->vars($data);
$this->load->view('welcome/template');
This is my username
function login(){
if ($this->input->post('email')){
$e = $this->input->post('email');
$pw = $this->input->post('password');
$this->MCustomers->verifyCustomer($e,$pw);
if (isset($_SESSION['customer_id'])){
$this->session->set_flashdata('msg', 'You are logged in!');
redirect('welcome/login','refresh');
}
$this->session->set_flashdata('msg', 'Sorry, your email or password is incorrect!');
redirect('welcome/login','refresh');
}
$data['main'] = 'welcome/customerlogin';
$data['title'] = "Customer Login";
$this->load->vars($data);
$this->load->view('welcome/template');
}
And logout
function logout(){
session_unset();
session_destroy();
redirect('welcome/index','refresh');
}
source
share