0
想要將鍵和值附加到已創建的會話。將陣列鍵值附加到會話數組
if (!isset($_SESSION['cart'])) {
$bag = array(
"sessionId" => session_id(),
"productId" => $productId,
"size" => $productSize,
"quantity" => $productQuantity
);
$_SESSION['cart'] = $bag;
} else {
$_SESSION['cart']['sessionId'] = session_id();
$_SESSION['cart']['productId'] = $productId;
$_SESSION['cart']['size'] = $productSize;
$_SESSION['cart']['quantity'] = $productQuantity;
}
如果會話已經被創建,然後使用它的關鍵字將新變量追加到會話中。
太好了,謝謝。將標記! – Zack1101