我想在会话中获取多个值并在我的结帐页面中显示产品。我的问题是会话中存储的id只有一个(最后选择的产品)
ajax.page
$cartArray = unserialize($_SESSION[['cart']]);//convert text to array (because $_session['cart'] is text)
$cartArray [] = $_POST['id'];
$_SESSION['cart'] = serialize($cartArray);//convert array to text (store)
结帐页面
我想要测试插入索引2
<?php
$idCart = unserialize($_SESSION['cart']);
$query = "select * from products where id=".$idCart[2];
$sel = $db->select($query);
$result = mysqli_fetch_assoc($sel);
$image = $result['image'];
$name = $result['name'];
$price = $result['price'];
?>