Code: Select all
if(isset($_SESSION['products'])) {
$products = $_SESSION['products'];
$products[] = array('id' => $id, 'quantity' => $quantity);
$_SESSION['products'] = $products;
}
else {
$products[] = array('id' => $id, 'quantity' => $quantity);
$_SESSION['products'] = $products;
}Tried the following code but it doesn't work.
Code: Select all
$_SESSION['products[]'] = array('id' => $id, 'quantity' => $quantity);