Welcome Guest, Not a member yet? Register   Sign In
Custom Session Data
#1

[eluser]snowstar[/eluser]
Hi all,

im trying to make sense of sessions. I believe im going wrong in the retrieving the right information from the db and pushing it back to the session

I'm trying to get the id from the same row as the user who has just been authenticated, i would like to get other information from other rows too.

My controller

Code:
function validate_credentials()
    {        
        $this->load->model('membership_model');
        $query = $this->membership_model->validate();
        
        if($query) // if the user's credentials validated...
        {
            
            $this->db->where('username');
            $this->db->select('id');
            $userid = $this->db->get('tbl_users');
            
            
            $data = array(
                'username' => $this->input->post('username'),
                'userid' => $userid,
                'is_logged_in' => true
            );
            $this->session->set_userdata($data);
            redirect('members_area');
        }
        else // incorrect username or password
        {
            $this->index();
        }
    }

My model

Code:
function validate()
    {
        $this->db->where('username', $this->input->post('username'));
        $this->db->where('password', md5($this->input->post('password')));
        $query = $this->db->get('tbl_users');
        
        if($query->num_rows == 1)
        {
            return true;
        }
        
        
    }

I think im going wrong with

Code:
$this->db->where('username');
$this->db->select('id');
$userid = $this->db->get('tbl_users');

if any one is able to point me in the right direction it would be most appreciated
#2

[eluser]nggakbiasa[/eluser]
try :
Code:
$this->db->where('name', $name);
http://ellislab.com/codeigniter/user-gui...ecord.html




Theme © iAndrew 2016 - Forum software by © MyBB