0
所以,我有我的會話內部有一個「購物車」點陣這樣笨 - 未設置會話數據(USER_DATA陣列內)
Array
(
[session_id] => 4a5a5dca22728fb0a84364eeb405b601
[ip_address] => 127.0.0.1
[user_agent] => Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7;
[last_activity] => 1303142623
[cart] => Array([1]=1;
[2]=3;
)
)
我的問題,我想取消設置車array..but內的一個ID不是整個「購物車」數據
$this->session->unset_userdata($id); //$id as in [cart][$id]
//or even like this below
$tmp = $this->session->userdata('cart');
$this->session->unset_userdata($tmp[$pid]);
我試過上面的,但它沒有做到這一點。幫幫我!
PS:我通過$ ID通過URI,可以呼應的$ id就好
========================= =========================== 更新: 感謝您的回覆,但我以某種方式解決了我的問題。我做了這樣的
$tmp = $this->session->userdata('cart');
unset($tmp[$pid]);
$this->session->set_userdata('cart',$tmp);
http://stackoverflow.com/questions/14561332/how-to- remove-the-single-cart-item-using-codeigniter-cart-class – sbaaaang
@sbaaaang:我沒有使用CI內置的購物車類 – user2960754