load->model("UserModel"); $this->load->library('form_validation'); } public function index() { if($this->session->userdata('user_logged')!==null){ if($this->session->userdata('user_logged')->level=='admin'){ redirect(site_url('admin/dashboard')); } else { redirect(site_url('dashboard')); } } if($this->input->post()){ if($this->UserModel->doLogin()) { redirect(site_url('admin/dashboard')); } else { $data['error']="Username atau Password salah !"; $this->load->view('login',$data); } } else { $this->load->view('login'); } } public function logout() { // hancurkan semua sesi $this->session->sess_destroy(); redirect(site_url('login')); } }