Hi Everyone, my session variable seems to keep dropping its array values. What could I be doing wrong? Is it my object?
session_start() is initiated at the beginning,
if(isset($_SESSION['locations'])) {
unserialize($_SESSION['locations'])->listItems($_POST['companyLocation']);
echo "session exists";
}
else{
$_SESSION['locations'] = serialize(new Location());
unserialize($_SESSION['locations'])->listItems($_POST['companyLocation']);
echo "session does not exist";
}
class Location{
function listItems($location){
$array;
$array[] = $location;
//print_r($array);
// Re-index:
$array = array_values($array);
print_r($array);
$count = count($array);
for ($i = 0; $i < $count; $i++) {
echo "{$array[$i]}\n";
}
}
}