Welcome Guest, Not a member yet? Register   Sign In
$_SESSION problem
#1

[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




Theme © iAndrew 2016 - Forum software by © MyBB