title: Codeigniter Login Issues
body: <p>I'm having difficulties in understanding what's going on here. </p>
  
  <p>I've made a login page, setting it to go to admin page. Without any user data yet, just to check if it's working. And It doesn't go. I hade some problems loading the <strong>library form_validation</strong>. So I added the parent construct.</p>
  
  <p>Controller</p>
  
  <p>
  
  <pre><code>class Login Extends CI_Controller{
  public function __construct()
  {
      parent::__construct();
      $this-&gt;load-&gt;helper('url'); 
  
  }
  
  public function index() {
  
      $this-&gt;load-&gt;view('login');
      $this-&gt;load-&gt;helper('url'); 
  
  }
  
  public function login() {
  
      $this-&gt;load-&gt;library('form_validation');
      $this-&gt;load-&gt;helper('url'); 
      $this-&gt;form_validation-&gt;set_rules('username','Username','trim|required');
      $this-&gt;form_validation-&gt;set_rules('password','Password','trim|required|md5');
      if($this-&gt;form_validation-&gt;run()==false){
          $this-&gt;index();
      }else{
          $user_session=array(
              'Username'      =&gt; $this-&gt;input-&gt;post('username'),
              'Password'      =&gt; $this-&gt;input-&gt;post('password'),
              'is_logged_in'  =&gt; 1
          );
          $this-&gt;session-&gt;set_userdata($user_session);
          redirect('login/admin');
      }
  
  }
  
  
  
  public function admin() {
      $this-&gt;load-&gt;view('admin');
  
  }
  
  }
  </code></pre>
  
  <p>My Login View</p>
  
  <pre><code> &lt;section class="login_content"&gt;
          &lt;?php echo validation_errors(); ?&gt;
          &lt;form action="&lt;?php echo base_url().'login/login'; ?&gt;" method="post"&gt;
          &lt;h1&gt;Login no Sistema&lt;/h1&gt;
          &lt;div&gt;
              &lt;input type="text" name="username" class="form-control" placeholder="Username" required="" /&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;input type="password" name="password" class="form-control" placeholder="Password" required="" /&gt;
          &lt;/div&gt;
          &lt;div&gt;
              &lt;input type="submit" name="submit" value="Login" /&gt;
  
          &lt;/div&gt;
          &lt;div class="clearfix"&gt;&lt;/div&gt;
          &lt;div class="separator"&gt;
  
  
            &lt;div class="clearfix"&gt;&lt;/div&gt;
            &lt;br /&gt;
            &lt;div&gt;
              &lt;h1&gt; Sitio Monica e Marcia&lt;/h1&gt;
  
              &lt;p&gt;©2016 Todos os direitos reservados. Sitio Monica e Marcia.&lt;/p&gt;
            &lt;/div&gt;
          &lt;/div&gt;
        &lt;/form&gt;
        &lt;!-- form --&gt;
      &lt;/section&gt;
  </code></pre>
  
  <p>My Admin View</p>
  
  <pre><code> &lt;div id="login" class="animate form"&gt;
      &lt;section class="login_content"&gt;
          &lt;h1&gt;Bem vindo ao Admin&lt;/h1&gt;
          &lt;?php 
              echo '&lt;pre&gt;';
              print_r($this-&gt;session-&gt;all_userdata());
              echo '&lt;pre&gt;';
  
          ?&gt;
        &lt;!-- form --&gt;
      &lt;/section&gt;
      &lt;!-- content --&gt;
    &lt;/div&gt;
  </code></pre>