title: Codeigniter Redirect to a controller
body: <p>I have different types of users with different functionalities, i want to redirect different users to their controllers,Is this a good practice in Codeigniter if yes how can i do that?</p>
  
  <pre><code>public function login() {
              $this-&gt;form_validation-&gt;set_rules('email', 'Email', 'required|valid_email');
              $this-&gt;form_validation-&gt;set_rules('password', 'Password', 'required');
              if ($this-&gt;form_validation-&gt;run() != FALSE) {
                  $db_data = array();
                  $db_data['email'] = $this-&gt;input-&gt;post('email', TRUE);
                  $db_data['password'] = $this-&gt;input-&gt;post('password', TRUE);
                  $res = $this-&gt;Fypms_model-&gt;auth_user($db_data);
                  if ($res-&gt;result_id-&gt;num_rows == 1) {
                      //$this-&gt;session-&gt;set_userdata($user);
                      $res = $res-&gt;result();
                      $this-&gt;session-&gt;set_userdata('user_id', $res[0]-&gt;user_id);
                      //redirect("users/changepassword");
  
                      switch ($res[0]-&gt;user_type) {
                          case "SA":
                              redirect("/superadmin/index");;
                              break;
  
                      }
                  } else {
                      $data['error'] = "Invalid Email or Password";
                  }
              }
          }
  </code></pre>