title: Codeigniter: Undefined variable: + Trying to get property of non-object
body: <p>I would like to show users full name and photo profile on the nav bar (just like social networking site navbar) using codeigniter 2.1.4,</p>
  
  <p>This is my model:</p>
  
  <pre><code>function saya(){
      $session_data = $this-&gt;session-&gt;userdata('logged_in');
      return $this-&gt;db-&gt;get_where('UserAplikasi', array('UserID' =&gt; $session_data['userid']))-&gt;row();
  }
  </code></pre>
  
  <p>Controller:</p>
  
  <pre><code>function index(){
      if($this-&gt;session-&gt;userdata('logged_in')){
          $data['saya'] = $this-&gt;m_saya-&gt;saya();
          $data['isi']   = "administrator/home/home_view";
          $this-&gt;load-&gt;vars($data);
          $this-&gt;load-&gt;view('administrator/template');
      }
      else{
  
          redirect('login', 'refresh');
      }
  }
  </code></pre>
  
  <p>And view:</p>
  
  <pre><code>&lt;?php echo $saya-&gt;NamaLengkap; ?&gt;
  </code></pre>
  
  <p>That code works in some page, but in the other page its error <strong>Undefined variable: saya and Trying to get property of non-object</strong>
  Can anybody help me, please?</p>