Skip to content

Commit e1bfbbb

Browse files
committed
Check to see if 'cart' session is set.
1 parent 14fe257 commit e1bfbbb

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

cart.php

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,13 @@
3434
include INC . 'header.php';
3535
include INC . 'nav.php';
3636

37-
$cart = $_SESSION['cart'];
38-
$count = count($cart);
37+
// Check to see if the cart is in the session data else default to null.
38+
// We do this because the $cart and $count variables are used extensively
39+
// below and will output warnings if we don't.
40+
if (isset($_SESSION['cart'])) {
41+
$cart = $_SESSION['cart'];
42+
$count = count($cart);
43+
}
3944
?>
4045

4146

inc/nav.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
$cart = $_SESSION['cart'];
77
$count = count($cart);
88
} else {
9-
$cart = '';
109
$count = 0;
1110
}
1211
?>

0 commit comments

Comments
 (0)