title: Conditional Routing in Codeigniter
body: <p>I've searched all over for this and can't seem to find a solution anywhere. Does anyone know how to setup a conditional route in CI? For example if the user is logged in then the <code>default_controller</code> should be <code>documents</code> but if not then it should be <code>home</code>. I've tried the obvious:</p>
  
  <pre><code>if ( $this-&gt;session-&gt;userdata('user_logged_in') ) {
  
      $route['default_controller'] = "documents";
  
  } else {
  
      $route['default_controller'] = "home";
  
  }
  </code></pre>
  
  <p>However this doesn't seem to work as I'm guessing the session isn't available until after the routes are set.</p>