title: calling function inside function with same class and redirect in codeigniter
body: <p>I am working on login and search functionality using <code>CodeIgniter</code>. </p>
  
  <blockquote>
    <p>What Exactly I am doing?</p>
  </blockquote>
  
  <p>When the user searches something in the search form and on submitting that form I put a check if the user is logged in then it will directly show the result &amp; if the user is not logged in then it redirects the user to the login page and I saved the search data in <code>session</code> as <code>search_session_data</code>.</p>
  
  <p>I have a controller which redirects user regarding the session. If the user came directly to the login page then the user is redirected to the dashboard after login. but if the user is coming from search page then the user is redirected to the search result page after login.</p>
  
  <p>I have mentioned the problem inside the code with a comment.</p>
  
  <p>This is the controller:</p>
  
  <pre><code>public function get_the_search_result() {
  
          $search_session_data = $this-&gt;session-&gt;userdata('search_session_data');
          $this-&gt;load-&gt;model ('my_model');
          $result_data = $this-&gt;my_model-&gt;find_data_regarding_search_criteria($search_session_data);
  
          $this-&gt;load-&gt;view ('app/app_statch_result',['result_data' =&gt; $result_data,]);
  }
  
  
  public function login_function() {
      //necessary  login code
  
      if ($this-&gt;session-&gt;userdata('search_session_data')) {
  
          //Here I want the if `search_session_data` available in session then 
          // user goest to `get_the_search_result` and view the
           //'app/app_statch_result` but it is not working.
  
          $this-&gt;get_the_search_result();
      } else {
          return redirect('dashboard');
      }
  
  }
  </code></pre>
  
  <blockquote>
    <p>So How do I redirect the user to <code>app_statch_result</code> from
    <code>login_function</code> function?</p>
  </blockquote>
  
  <p>Any suggestion regarding improvement is applicable. Thanks </p>