SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Member
    Join Date
    Apr 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    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 Code:
    <?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 Code:
    <?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>
    Last edited by ScallioXTX; Apr 24, 2014 at 08:28. Reason: Wrapped code in [php][/php]

  2. #2
    From Italy with love silver trophybronze trophy
    guido2004's Avatar
    Join Date
    Sep 2004
    Posts
    9,500
    Mentioned
    163 Post(s)
    Tagged
    4 Thread(s)
    Put session_start(); at the beginning of each script

  3. #3
    SitePoint Member
    Join Date
    Apr 2014
    Posts
    2
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •