üstüne geliştirebilirsiniz:
<?php
session_start();
$products = ['kabak','un','elma','muz'];
if(isset($_POST['addtocart'])){
    $_SESSION['cart'] = $_POST['products'];    
    if(in_array('kabak',$_SESSION['cart'])){
        if(!in_array('un',$_SESSION['cart'])){
            array_push($_SESSION['cart'], 'un');
        }
    }
}
if(isset($_POST['clearcart'])){
    unset($_SESSION['cart']);
}
?>
<html>
<body style="background:black;color:white;display:table;margin:100px auto 0 auto;">
    <?php if(isset($_SESSION['cart'])): ?>
    <h2>Sepetim</h2>
    <ul>
        <?php foreach($_SESSION['cart'] as $cartVal): ?>
        <li><?php echo $cartVal; ?></li>
        <?php endforeach; ?>
    </ul>
    <?php endif; ?>
    <form method="post" action="">
        <?php foreach($products as $productsKey => $productsVal): ?>
        <div style="display:block;">
            <input value="<?php echo $productsVal; ?>" type="checkbox" name="products[]" id="product-<?php echo $productsKey; ?>">
            <label for="product-<?php echo $productsKey; ?>"><?php echo $productsVal; ?></label>
        </div>
        <?php endforeach; ?>
        <input type="submit" name="addtocart" value="sepete ekle" />
    </form>
    <form method="post" action="">
        <input type="submit" name="clearcart" value="sepete temizle" />
    </form>
</body>
</html>