title: Codeigniter: Redirect not working
body: <p>I've searched through some of the other posts on here with this similar issue, but I haven't managed to make this work. don't know what the problem is.<br></p>
  
  <ul>
  <li>I'm trying to redirect to the main <code>Home</code> controller after logon/logout from the <code>Login</code> controller<br></li>
  </ul>
  
  <p>I have the <code>error_reporting(E_ALL)</code> set in my development environment variables and there's no error and tried loading the url helper in my <code>Login</code> controller: <code>$this-&gt;load-&gt;helper('url');</code></p>
  
  <p>Here is the main <code>Home</code> controller:</p>
  
  <pre><code>public function index() {
          if (($this-&gt;session-&gt;userdata('username') != "")) {
              $this-&gt;user();
          } else {
              $this-&gt;load-&gt;view('login');
          }
      }
  </code></pre>
  
  <p>Here's the <code>Login</code> controller:</p>
  
  <pre><code>public function index()
      {
          $this-&gt;load-&gt;view('login');
      }
      public function logout()
      {
                  $profile = array(
                      'userid' =&gt; '',
                      'username' =&gt; '',
                      'role' =&gt; '',
                      'custid' =&gt; '',
                      'custname' =&gt; '',
                      'logged_in' =&gt; FALSE 
                      );
  
          $this-&gt;session-&gt;unset_userdata($profile);
          $this-&gt;session-&gt;sess_destroy();
          redirect('/', 'refresh');
      }
      public function logon()
      {
          $data = $_POST;
          $this-&gt;db-&gt;select("people.*, customers.name as 'custname', customers.id as 'custid'");
          $this-&gt;db-&gt;from('people');
          $this-&gt;db-&gt;join('customers', 'customers.id = people.customer');
          $this-&gt;db-&gt;where('people.username', $data['username']);
          $this-&gt;db-&gt;where('people.password', $data['password']);
          $query = $this-&gt;db-&gt;get();
          $results = $query-&gt;result_array();
  
          if(count($results) &gt; 0)
          {
              $profile = array(
                 'username'  =&gt; $results[0]['username'],
                 'userid'  =&gt; $results[0]['id'],
                 'role'  =&gt; $results[0]['role'],
                 'date_format'  =&gt; $results[0]['date_format'],
                 'custname' =&gt; $results[0]['custname'],
                 'custid' =&gt; $results[0]['custid'],
                 'logged_in' =&gt; TRUE
              );
  
              $this-&gt;db-&gt;select("*");
              $this-&gt;db-&gt;from('hub.settings');
              $this-&gt;db-&gt;where('customer', $profile['custid']);
              $query = $this-&gt;db-&gt;get();
              $results = $query-&gt;result_array();
              if(count($results) &gt; 0)
              {
                  $profile['contacthtml'] = $results[0]['contacthtml'];
                  $profile['accentcolor'] = $results[0]['accentcolor'];
              }
  
              $this-&gt;session-&gt;set_userdata($profile);
              redirect('/', 'refresh');
          }else{
              redirect('/login', 'refresh');
          }
      }
  </code></pre>
  
  <p>All I'm getting is the url <code>http://localhost:85/login/logon</code> and a blank screen.<br><br>
  I've also tried: <code>redirect('/home', 'refresh');</code>, <code>redirect('/home');</code>, <code>redirect('home', 'refresh');</code>, <code>redirect('home/', 'refresh');</code>, <code>redirect('/home/', 'refresh');</code></p>
  
  <p>EDIT:</p>
  
  <p>This is the response from Network section in dev tools:</p>
  
  <p><img src="https://i.stack.imgur.com/rqbAz.png" alt="enter image description here"></p>