php - How to access all userdata via session in codeigniter -


please have created login , passed email , id , can access them in view. unable access other userdata name, phone, etc. able access email, id , session id. appreciated.

here model

public function login($email, $password){     $this->db->select('*');     $this->db->from($this->table);     $this->db->where('email', $email);     $this->db->where('passwd', $password);     $this->db->limit(1);      $query = $this->db->get();      if ($query->num_rows() == 1) {         return $query->row()->uid;     }     else {         return false;     }  } 

here controller

public function login(){      $this->form_validation->set_rules('email', 'email', 'trim|required');     $this->form_validation->set_rules('password', 'password', 'trim|required');   if($this->form_validation->run() == false) {      echo validation_errors('<p class="alert alert-dismissable alert-danger">'); } else{          //get post data         $email = $this->input->post('email');         $password = $this->input->post('password');          $enc_pwd = sha1($password);         $id = $this->user_model->login($email, $enc_pwd);          if($id){             $userdata = array(                 'id'        =>  $id,                 'email'     =>  $email,                 'logged_in' =>  true                 );               //set session data             $this->session->set_userdata($userdata);               //redirect users page             redirect('site/dashboard');         }         else{             //create error             $this->session->set_flashdata('error', 'login credentials incorrect');               //redirect users page             redirect('site/login');         }          //add activity         //$this->activity_model->add($data);                 }      //load login template     $this->load->view('public/login');  } 

you can set sesssion in model

refer code below.check how set other variables in session

model

function login($email, $password) {     $this -> db -> select('*');     $this -> db -> from($this->table);     $this->db->where('email', $email);     $this->db->where('passwd', $password);     $this->db->limit(1);     $query = $this -> db -> get();       if($query -> num_rows() == 1)     {         $row = $query->row();         $data = array(         'email'=>  $email,         'id' => $row->id,         'name' => $row->name,         'phone' => $row->phone,         'logged_in' =>  true          );         $this->session->set_userdata($data);         return true;      }     else     {         return false;     }   } 

anywhere can call session variable.