title: How can I resolve cross sessions in CodeIgniter?
body: <p>I am currently having a problem with the sessions at the time of logging in with a user, when the user starts the session, the session takes the data of another user who is connected to the system on another computer and also shows sales data that the other user is performing, sometimes refreshing the site returns to normal.</p>
  
  <p>HomeController.php</p>
  
  <pre><code>public function login()
  {
      $username = $this-&gt;input-&gt;post('username');
      $password = $this-&gt;input-&gt;post('password');
  
      $usuario = $this-&gt;Modelousuarios-&gt;verificar_usuario($username, md5($password));
  
      if($usuario){
          $permisos = $this-&gt;Modelousuarios-&gt;permisos($usuario-&gt;codigousuario);
          $this-&gt;login_success($usuario, $permisos);
      }
      else{
          $this-&gt;login_fail();
      }
  }
  
  private function login_success($usuario, $permisos)
  {
      $session_data = array(
          'autenticado' =&gt; TRUE,
          'nombre_usuario' =&gt; $usuario-&gt;nombreusuario,
          'nombre' =&gt; $usuario-&gt;nombre,
          'codigo' =&gt; $usuario-&gt;codigousuario,
          'tipo_usuario' =&gt; $usuario-&gt;tipousuario,
          'codigolocal' =&gt; $usuario-&gt;codigolocal,
          'permisos' =&gt; $permisos
      );
  
      //Quitando los datos de la session si existen
      $this-&gt;session-&gt;unset_userdata($session_data);
  
      $this-&gt;session-&gt;set_userdata($session_data);
  
      redirect('facturacion/realizar-venta');
  }
  </code></pre>
  
  <p>Modelousuarios.php</p>
  
  <pre><code>function verificar_usuario($user, $pass) {
      $query = $this-&gt;db-&gt;query("select * from usuarios where nombreusuario='{$user}' and contrasena='{$pass}' and estado = 1 ");
  
      if ($query-&gt;num_rows() &gt; 0) {
          return $query-&gt;row();
      } else {
          return false;
      }
  }
  </code></pre>
  
  <p>This is my current session configuration in config.php</p>
  
  <pre><code>$config['sess_driver'] = 'database';
  $config['sess_cookie_name'] = 'ci_session';
  $config['sess_expiration'] = 0;
  $config['sess_save_path'] = 'ci_sessions';
  $config['sess_match_ip'] = FALSE;
  $config['sess_time_to_update'] = 0;
  $config['sess_regenerate_destroy'] = FALSE;
  </code></pre>
  
  <p>I hope you can help me, this problem is driving me crazy... Sorry for my english, regards.</p>