title: Unserialize Database Session Codeigniter
body: <p>I do have an issue with Codeigniter Database Session.</p>
  
  <p>To make it short, I don't want multiple login with the same credentials(login/password).</p>
  
  <p>The first verification is made by username/passwod matches in the database.</p>
  
  <p>Here is my code</p>
  
  <pre><code>function index()
  {
      // Load Model.
      $this-&gt;load-&gt;model('membres_model');
  
      // Check if the user is already logged
      if($this-&gt;session-&gt;userdata('alias') || $this-&gt;session-&gt;userdata('logged'))
      {
          //Redirect if he is logged.
          redirect('membres/');
      }
      // If the form has been sent.   
      if($this-&gt;input-&gt;post('submit'))
      {           
          // Trim data
          $this-&gt;form_validation-&gt;set_rules('alias','Nom d\'utilisateur','trim|required|xss_clean');
          $this-&gt;form_validation-&gt;set_rules('motdepasse','Mot de passe','trim|required|xss_clean');
  
          if($this-&gt;form_validation-&gt;run())
          {
              // check verification in the model
              if($this-&gt;membres_model-&gt;verification_connexion($this-&gt;input-&gt;post('alias'),$this-&gt;input-&gt;post('motdepasse')))
              {
                  // Set userdata variables
                  $data = array(
                      'alias'     =&gt;  $this-&gt;input-&gt;post('alias'),
                      'addr_ip'   =&gt;  $_SERVER['REMOTE_ADDR'],
                      'hote'      =&gt;  gethostbyaddr($_SERVER['REMOTE_ADDR']),
                      'logged'    =&gt;  true
                  );
  
                      /****************************************
                      I Want to verify if the membres is already logged if another one want to use the                        same login/password of the logged on. but I don't know how to verify in the                         ci_sessions
                      *****************************************/
  
                      // start session
                      $this-&gt;session-&gt;set_userdata($data);
                      // Redirection sur l'espace membre apres la creation de la session.
                      redirect('membres/');
              }
              else {
                  // if return false
                  $data['error'] = 'Mauvais identifiants';
                  $data['contenu'] = 'connexion/formulaire';
                  $this-&gt;load-&gt;view('includes/template',$data);
              }
          } 
          else {
  
              $data['contenu'] = 'connexion/formulaire'; // La variable vue pour loader dans le template.
              $this-&gt;load-&gt;view('includes/template',$data);
          }
  
      } 
      else {
  
          $data['contenu'] = 'connexion/formulaire'; // La variable vue pour loader dans le template.
          $this-&gt;load-&gt;view('includes/template',$data);
      }
  
  }
  }
  </code></pre>
  
  <p>I know I do have to use session Unserialize. I can't get the array but I don't know how to compare the data with the logged user. Does anybody can help me ?</p>