title: Codeigniter - how to pass variable without load view
body: <p>I have this data in my controller to load a view:</p>
  
  <pre><code>private $data //defined before my construct function
  
  function index(){
      $this-&gt;data['myvar'] = 'test'
      $this-&gt;load-&gt;view('homeview', $this-&gt;data);
  }
  </code></pre>
  
  <p>But the problem is that I want to access the <code>$this-&gt;myvar</code> variable in the other view from <code>homeview</code> like <code>maincontentview</code> (it includes it inside <code>homeview</code>). My question is how can I pass a variable to <code>maincontentview</code> without loading it (<code>like $this-&gt;load-&gt;view('maincontentview', $this-&gt;data)</code>).</p>