Question: i have one login page in that i have two user\_types..one is vendor and another one is user..

So..what i want to do is whenever user or vendor logged in from login..they have to redirect to dashboard..in that i want to get that user\_id in the URL..

Here is my login Controller:

public function signin()
 {

```
    $data['error'] ="Invalid Login";
             if($this->input->post())
           {

              $user = $this->LoginModel->login($this->input->post());
              if(count($user)>0)
                {
                       $data = array(
                             'user_id' => $user['user_id'],
                             'first_name' => $user['first_name'],
                             'email' => $user['email'],
                             'password' => $user['password']
                            );

              $this->session->set_userdata($data);

           if($user['user_type_id'] == '1')
          {

                  redirect(base_url('index.php/Login/vendor_dashboard'));

          } 

        elseif($user['user_type_id'] == '2')
         {
              redirect(base_url('index.php/Login/user_dashboard'));
         }

        else
        {
          redirect(base_url('index.php/Login/dashboard'));
        }

         }
     else
     {
         $data["error_message"]="Invalid User Name and Password combination";
     }
}

```

$this->load->view('Admin/login\_view',$data);

}

This is my Model:

```
function login($post='')
{
 $this->db->where(array('email' => $post['email'], 'password' => $post['password']));
 $query = $this->db->get('users');

 return $query->row_array();
}

```

Please someone help me..

How to do this..

Thanks in advance..

Answer: 
try this:

```
redirect(base_url('index.php/Login/vendor_dashboard?user_id='.$user['user_id'])

```
login post form function

```
public function login()
{
    //fetch form data
     ---------------
    //set session
    this->session->set_userdata('userName', $username);
    $this->session->set_userdata('userId', $userid);
    //redirect 
    $this->user_dashboard();  
}
public function user_dashboard(){
  if(isset($_SESSION['userId'])){
  $data['usertype']= $_SESSION['userId'];//0=admin,1=vender etc
 }
  if()
   {//}
   else
   {//}
}

```

use

```
<?php redirect(base_url('index.php/user_dashboard'), 'refresh'); ?>

```