title: Codeigniter - Adding Code to Constructor without affected to Specific Controller Function
body: <p><strong>Short Version of this question</strong></p>
  
  <p>How to write something like this (<code>if(Controller Function is Not "Login()" Function)</code>) in Codeigniter Constructor?</p>
  
  <pre><code>if(Controller Function is Not "Login()" Function)
  {
      if(empty($this-&gt;session-&gt;userdata('user_id'))){
          redirect(base_url());
      }
  }
  </code></pre>
  
  <p><strong>Long Version of this question if is not clear the short version</strong></p>
  
  <p>This is Admin controller of my codeigniter project</p>
  
  <pre><code>class Admin extends CI_Controller
  {
      public function __construct()
      {
          parent::__construct();
          /**
          * 
          * 
          *  Here - I am going to check session is set or not.....
          * 
          * 
          */
  
      }
  
      public function login(){
  
      }
  
      public function update(){
  
      }
  
      public function edit(){
  
      }
  
      public function insert(){
  
      }
  
          /**
          * 
          * 
          *  And Many More Functions
          * 
          * 
          */
  
  }
  </code></pre>
  
  <p>I am going to add following code part to <strong>constructor</strong>.</p>
  
  <pre><code>if(empty($this-&gt;session-&gt;userdata('user_id'))){
      redirect(base_url());
  }
  </code></pre>
  
  <p>When I write this even I can't go to the <code>login()</code> function without session. How to write above code in <strong>constructor</strong> which not affect to the login function. </p>
  
  <p>I am looking something like this,</p>
  
  <pre><code>if(Controller Function is Not "Login()" Function)
  {
      if(empty($this-&gt;session-&gt;userdata('user_id'))){
          redirect(base_url());
      }
  }
  </code></pre>