Welcome Guest, Not a member yet? Register   Sign In
data pass through session
#4

[eluser]zreedeecom[/eluser]
Take a look at: User guide > Database Library > Query Results

Code:
function get_user_id(){
  $this->db->where('username', $this->input->post('username'))->where('password', $this->input->post('password'));
  $q = $this->db->get('users');
  if ( $q->num_rows() > 0 ) {
    //do something with: $q->result() or $q->row()
    $row = $q->row();
    //Now you can store that ID in a session
    $this->session->set_userdata('user_id', $row->id);
    //or you can return it to your controller to perform other actions
    return $row->id;
  }
  else {
    //No records founded
  }
} //end get_user_id()


Messages In This Thread
data pass through session - by El Forum - 08-23-2010, 04:52 AM
data pass through session - by El Forum - 08-23-2010, 09:18 AM
data pass through session - by El Forum - 08-25-2010, 12:47 AM
data pass through session - by El Forum - 08-25-2010, 02:58 AM
data pass through session - by El Forum - 08-26-2010, 02:50 AM
data pass through session - by El Forum - 08-26-2010, 04:20 AM
data pass through session - by El Forum - 08-27-2010, 11:19 PM
data pass through session - by El Forum - 08-28-2010, 04:50 AM



Theme © iAndrew 2016 - Forum software by © MyBB