load->helper('cookie'); } public function index() { $user_info = $this->session->userdata('userInfo'); if ($user_info) { redirect('/frontend/lecture'); }else{ $cookie_name = "siteCookie"; if(isset($_COOKIE[$cookie_name])){ $arr_user = parse_str($_COOKIE[$cookie_name]); $user_info = array( 'username' => $arr_user['username'], "logined_in" => TRUE); $this->session->set_userdata('userInfo', $user_info); redirect('/frontend/lecture'); }else{ $this->load->view ( 'home'); } } } public function test() { if (isset($_POST['submit'])){ $this->signin(); } } public function signin() { $username = $this->input->post('username', TRUE); $password = $this->input->post('password', TRUE); $autologin = ($this->input->post('remember_me') == 'on') ? 1 : 0; $token = md5($username.self::TOKENPW); $this->load->model(array('user_model')); $data = $this->user_model->checkLogin('violet', $token, $username, $password); if ($data == null) { $this->session->set_flashdata('login_error', TRUE); redirect('/frontend/home'); }else{ $arr_users = explode("&", $data); $str_status = ""; $str_fullname = ""; $fullname = ""; for ($i=0; $i $username, "logined_in" => TRUE); $this->session->set_userdata('userInfo', $userdata); redirect('/frontend/lecture'); break; case 1: $this->session->set_flashdata('login_error', TRUE); redirect('/frontend/home'); break; case 2: case 3: $this->session->set_flashdata('login_error', TRUE); redirect('/frontend/home'); break; case 4: redirect('/frontend/home'); break; case 10: $this->session->set_flashdata('login_error_token', TRUE); redirect('/frontend/home'); break; default: break; } } } public function signout() { $this->session->sess_destroy(); //unset($this->session->userdata); $cookie_name = "siteCookie"; setcookie($cookie_name, 'username='."", time() - 3600); redirect('/frontend/home'); } } /* End of file home.php */ /* Location: ./application/modules/frontend/controllers/home.php */