$_SESSION problem - Printable Version +- CodeIgniter Forums (https://forum.codeigniter.com) +-- Forum: Archived Discussions (https://forum.codeigniter.com/forumdisplay.php?fid=20) +--- Forum: Archived Development & Programming (https://forum.codeigniter.com/forumdisplay.php?fid=23) +--- Thread: $_SESSION problem (/showthread.php?tid=15463) |
$_SESSION problem - El Forum - 02-05-2009 [eluser]nir[/eluser] Hello All, by following the book Professional CodeIgniter(Worx) in the login section it is using the $_SESSION['userid'] as follows: Controller =============================================================================== function verify() { if($this->input->post('username')){ $u = $this->input->post('username'); $pw = $this->input->post('password'); $this->MUsers->verifyUser($u,$pw); if ($_SESSION['userid'] > 0){ redirect('admin/dashboard','refresh'); } } $data['main'] = 'login'; $data['title'] = 'ADMIN | Dashboard'; $data['navList'] = $this->MCats-getCategoriesNav(); $this->load->vars($data); $this->load->view('template',$data); } ====================================================================================== Model ====================================================================================== function verifyUser($u,$pw){ $this->db->select('id,username'); $this->db->where('username',$u); $this->db->where('password',$pw); $this->db->where('status', 'active'); $this->db->limit(1); $Q = $this->db->get('ctl_users'); if ($Q->num_rows() > 0){ $row = $Q->row_array(); $_SESSION['userid'] = $row['id']; $_SESSION['username'] = $row['username']; } else { $this->session->set_flashdata('error', 'Sorry, your username or password is incorrect!'); } } ===================================================================================== the problem is that the $_SESSION['userid'] is grater than 0 even if the user/password do not match??? thank you, nir |