title: Login in codeigniter
body: <p>I am trying to login  using the following code. Is there any  problem with this code? please provide correct code for login ..</p>
  
  <p>Controller:</p>
  
  <pre><code>public function login() {
      $data = $this-&gt;data;
      $email = $this-&gt;input-&gt;post('email');
      $password = md5($this-&gt;input-&gt;post('password'));
      $result = $this-&gt;user_model-&gt;login($email, $password);
  
      if (count($result) !== 0) {
          $this-&gt;session-&gt;set_userdata('user_id', $email);
          $seid = $this-&gt;session-&gt;userdata('user_id');
          if ($seid == '') {
              redirect(site_url());
  
          } else {
              redirect('home/view');
          }
      } else {
          redirect('home/index');
      }
  }
  </code></pre>
  
  <p>Model:</p>
  
  <pre><code>function login($email, $password) {
      $this-&gt;db-&gt;where("email", $email);
      $this-&gt;db-&gt;where("password", $password);
      $query = $this-&gt;db-&gt;get("user");
      return $query-&gt;result_array();
  }
  </code></pre>