title: Calling a Controller function in another Controller in CodeIgniter
body: <p>I have a controller "user" in my codeigniter application. This controller has a function called <code>logged_user_only()</code>:</p>
  
  <pre><code>public function logged_user_only()
      {
          $is_logged = $this -&gt; is_logged();
          if( $is_logged === FALSE)
          {
              redirect('user/login_form');
          }
      }
  </code></pre>
  
  <p>As this function calls another function called <code>is_logged()</code>, which just checks if the session is set, if yes it returns true, else returns false.</p>
  
  <p>Now if i place this function in the begining of any function within same controller, it will check if the user is not logged, it will redirect to <code>login_form</code> otherwise continue. This works fine.
  For example, </p>
  
  <pre><code>public function show_home()
      {
          $this -&gt; logged_user_only();
          $this-&gt;load-&gt;view('show_home_view');
      }
  </code></pre>
  
  <p>Now I would like to call this <code>logged_user_only()</code> function in a function of another controller to check if the user is logged in or not? </p>
  
  <p>PS. If this can not be done, or is not recommended, where should i place this function to access in multiple controllers? Thanks.</p>