title: Codeigniter - unset session data (inside user_data array)
body: <p>So I have a 'cart' array inside my session like this</p>
  
  <pre><code>Array
  (
  [session_id] =&gt; 4a5a5dca22728fb0a84364eeb405b601
  [ip_address] =&gt; 127.0.0.1
  [user_agent] =&gt; Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
  [last_activity] =&gt; 1303142623
  [cart] =&gt; Array( [1]=1;
                   [2]=3;
                  )
  )
  </code></pre>
  
  <p>My question, I want to unset one of the id inside cart array..but not the whole 'cart' data</p>
  
  <pre><code>$this-&gt;session-&gt;unset_userdata($id); //$id as in [cart][$id]
  //or even like this below
  $tmp = $this-&gt;session-&gt;userdata('cart');          
  $this-&gt;session-&gt;unset_userdata($tmp[$pid]);
  </code></pre>
  
  <p>I tried the above, but it doesn't do a thing. Help!</p>
  
  <p>PS: I pass the $id through uri and can echo the $id just fine</p>
  
  <p>====================================================
  update:
  Thank you for your replies, but I somehow resolved my problem. I did it like this</p>
  
  <pre><code>$tmp = $this-&gt;session-&gt;userdata('cart');          
  unset($tmp[$pid]);
  $this-&gt;session-&gt;set_userdata('cart',$tmp);
  </code></pre>