Welcome Guest, Not a member yet? Register   Sign In
Having a problem with sessions in codeigniter
#1

[eluser]afro[/eluser]
am trying to get the role name a role from the database, but am getting a null value, can
someone help me out
Here is the model.
Code:
function userdata()
            {
                
          
$q = $this->db->select('username, password');
$this->db->from('users');
$array = array('username' =>$this->input->post('username'), 'password' => md5($this->input->post('password')));
  $this->db->like($array);
  $this->db->select('name');
  $this->db->join('roles', 'users.role_id = roles.id','inner');
            
            
    $results['name'] = $q->get()->result();
            
            
            return $results;
            
            
            
            }
The controller is has follows

Code:
if($results)
    {
                      
         $role_name = '';
         $results = $this->users->userdata();
         $role_name = $results['name'];
                      
         $sessiondata = array(
        'username' => $this->input->post('username'),
        'role', $role_name->name,
       'logged_in' =>true
          );
       $this->session->set_userdata($sessiondata);
                    
                    
          $data['results'] = $results;
        $this->load->view('frontend/home',$data);
                  
         }




Theme © iAndrew 2016 - Forum software by © MyBB