I have a cart class that returns the products in a users cart
cart.class.php
public static function getItems()
{
if(!isset($_SESSION["cart"]["products"]))
{
return array();
}
else
{
return $_SESSION["cart"]["products"];
}
}
This is the code to get the cart and display it on the page
if($action == "getCart")
{
echo json_encode(Cart::getItems());
exit;
}
When I'm testing the code on my localhost, it returns [] (Empty) but on my website it returns null. What have I done wrong?
null?getItems()or thejson_encode()?