Session Array help

Hi all,

Wonder if anyone can help me, ive been stuck on this problem for a good few hours now. I am creating a pizza ordering system and i am trying to send data from one page to another through the use of a Session array from page2.php to page3.php. The session works fine until there are 4 or more variables in the session array, then i get the error message:

‘Notice: Undefined index: array_name in Page3.php on line 10’

Thanks.

My code is:

Page2.php:


<?php
require_once './class.UserSession.php';


$user = new UserSession(new Database());


$_SESSION['array_name'] = array('hello');
            //$_SESSION['array_name'] = array('hello?');


        foreach($_POST as $name => $value) {
      

            array_push($_SESSION['array_name'], $name);


        }
     
        print_r($_SESSION['array_name']);


page3.php:


<?php
require_once './class.UserSession.php';



$user = new UserSession(new Database());



print_r($_SESSION['array_name']);



?>

<!DOCTYPE html>
<html lang="en">
<link rel="stylesheet" type="text/css" href="loggedInStyle.css">
<head>
    <meta charset="utf-8">
    <title>User session assignment - Page 22222222</title>
</head>
<body>




</body>
</html>

Put session_start(); at the beginning of each script

i have Session_start in the included files at the top of each script. that cant be the prolem as it works wihen there are only 3 variables in the session array