Question: Heya I get this error message. I've been looking everywhere but I dont know how to fix it? Im a beginner so I'm really confued. Thanks in advance

Notice: Undefined index: cart in /nas/students/j/j39-green/unix/public\_html/ISD5/inc/functions.inc.php on line 3

You have no items in your shopping cart

```
<?php
function writeShoppingCart() {
$cart = $_SESSION['cart'];
if (!$cart) {
    return '<p>You have no items in your shopping cart</p>';
} else {
    // Parse the cart session variable
    $items = explode(',',$cart);
    $s = (count($items) > 1) ? 's':'';
    return '<p>You have <a href="cart.php">'.count($items).' item'.$s.'  in your shopping cart</a></p>';
}
}

```

Answer: 
Use "EMPTY":

```
<?php
function writeShoppingCart() {
    $cart = !empty($_SESSION['cart']);
    if (!$cart) {
        return '<p>You have no items in your shopping cart</p>';
    } else {
        // Parse the cart session variable
        $items = explode(',',$cart);
        $s = (count($items) > 1) ? 's':'';
        return '<p>You have <a href="cart.php">'.count($items).' item'.$s.'  in your       shopping cart</a></p>';
    }
}

```
That means that your session does not contain `$_SESSION['cart']`

Try this instead:

```
$cart = isset($_SESSION['cart']) ? $_SESSION['cart'] : false;

```