i dont know what problem about it
but i suggest you use session like this,
assuming there are 2 page named a.php and b.php
a.php
session_start();
$cart = array();
$_SESSION['cart'] = $cart; //register the $cart array as a variable
b.php
if (isset($SESSION['cart']) //check if the variable is register
//the same as session_is_registered()
$cart = $SESSION['cart']; //get the array back
$_SESSION = array() //the same as session_unregister()
//then destroy the session
session_destroy();