Welcome Guest, Not a member yet? Register   Sign In
Help session grab user_id from database
#5

[eluser]the_unforgiven[/eluser]
Controller to check login then store some session data:
Code:
function check()
{
  // Check user and password
  $query = $this->user_model->checkUser();
  
  $username = $this->input->post('username');
  $password = sha1($this->input->post('password'));
  
  $this->form_validation->set_rules('username', 'required|trim|max_length[15]');
  $this->form_validation->set_rules('password', 'required|trim|sha1');
    
  if ($this->form_validation->run() === FALSE) {
  
   $data['title'] = "Customer Login";
   $this->load->view('user/logon', $data);
  }
  else {
   if($query) {
    $data = array(
                 'username'    => $this->input->post('username'),
     'is_user'     => true,
     'last_login'  => time(),
     'customer_id' => $this->user_model->getCustomer(),
     'cust_id'     => $this->session->userdata('id')
              );
    
    $this->session->set_userdata($data);
    redirect('user/myaccount');
   }
  }
}

Model to getCustomer()
Code:
function getCustomer()
{
   $data = array();

   $Q = $this->db->get('users');
   if ($Q->num_rows() > 0){
        $data = $Q->row_array();
   }
     $Q->free_result();    
     return $data;
}


Messages In This Thread
Help session grab user_id from database - by El Forum - 05-23-2012, 08:16 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:36 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:40 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:43 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:45 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:52 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:56 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 08:58 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:01 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:06 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:07 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:13 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:15 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:20 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 09:21 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:19 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:22 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:25 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:29 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:30 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:37 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 10:42 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 11:07 AM
Help session grab user_id from database - by El Forum - 05-23-2012, 12:42 PM
Help session grab user_id from database - by El Forum - 05-24-2012, 08:50 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 09:06 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 09:16 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 09:35 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 09:37 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 10:30 AM
Help session grab user_id from database - by El Forum - 05-24-2012, 10:41 AM
Help session grab user_id from database - by El Forum - 05-25-2012, 08:57 AM
Help session grab user_id from database - by El Forum - 05-25-2012, 08:12 PM
Help session grab user_id from database - by El Forum - 05-25-2012, 08:29 PM
Help session grab user_id from database - by El Forum - 05-26-2012, 12:35 AM
Help session grab user_id from database - by El Forum - 05-26-2012, 03:01 AM
Help session grab user_id from database - by El Forum - 05-26-2012, 03:37 AM
Help session grab user_id from database - by El Forum - 05-26-2012, 09:03 AM
Help session grab user_id from database - by El Forum - 05-26-2012, 11:35 AM
Help session grab user_id from database - by El Forum - 05-28-2012, 01:35 AM
Help session grab user_id from database - by El Forum - 05-28-2012, 03:13 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 04:40 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 07:56 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 09:52 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 09:54 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 11:37 AM
Help session grab user_id from database - by El Forum - 05-29-2012, 12:57 PM
Help session grab user_id from database - by El Forum - 06-09-2012, 09:07 PM
Help session grab user_id from database - by El Forum - 06-11-2012, 12:59 PM



Theme © iAndrew 2016 - Forum software by © MyBB