load->model('UserModel'); } public function index() { $location = site_url('welcome'); header("Location: ".$location); } public function login() { $data['username'] = $_POST['username']; $data['password'] = $_POST['password']; $result = $this->UserModel->login($data); if (isset($result)){ $newdata = array( 'username' => $result->username, 'type' => $result->type, 'logged_in' => TRUE ); $this->session->set_userdata($newdata); $location = site_url('welcome'); header("Location: ".$location); }else{ $location = site_url('welcome'); header("Location: ".$location); } } public function logout(){ $deldata = array('username','type','logged_in'); $this->session->unset_userdata($deldata); $location = site_url('welcome'); header("Location: ".$location); } } ?>