當客戶選擇導航系統時,您需要將客戶導航選項保存在數據庫中。
使用日誌中。
從數據庫中提取數據。
我在控制器中提取這樣的客戶信息。
...
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');
這是我的登錄控制器/登錄
function login(){
// $data['loggedin']=0;
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'])){
// $data['loggedin']=$_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';// this is using views/login.php
$data['title'] = "Customer Login";
$this->load->vars($data);
$this->load->view('welcome/template');
}
和註銷
function logout(){
// or this would remove all the variable in the session
session_unset();
//destroy the session
session_destroy();
redirect('welcome/index','refresh');
}