title: How to keep a session alive after logging in (Codeigniter)
body: <p>We are building a webshop based on Codeigniter. Products are saved in a shopping cart with help of Codeigniters' Cart Class.</p>
  
  <p>When a visitor logs in with it's account, all products which are already in their cart are removed because a new session started when the user logged in.</p>
  
  <p>How can we keep the products in the cart at this point?</p>
  
  <pre><code>if($query-&gt;num_rows() == 1)
      {
          $user = $query-&gt;row_array();
          $data = array(
                  'userid' =&gt; $user['id'],
                  'email' =&gt; $user['email'],
                  'validated' =&gt; true
                  );
          $this-&gt;session-&gt;set_userdata($data);
  
          return true;
      }
  </code></pre>