SitePoint Sponsor

User Tag List

Results 1 to 6 of 6
  1. #1
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    $HTTP_SESSION_VARS in PHP v4.0?

    Does $HTTP_SESSION_VARS[] work in PHP v4.0?

    If not, how do you program for session variables with "register_globals" off?
    John

  2. #2
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Yes, its only the new variables ($_SESSION) that were introduced in 4.1.0

    BTW you should upgrade

  3. #3
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Ok. I ask this because I have a line in one script:
    PHP Code:
    $HTTP_SESSION_VARS["message"] = "Thank you!"
    And then in another script I have:
    PHP Code:
    $message = isset($HTTP_SESSION_VARS["message"]) ? $HTTP_SESSION_VARS["message"] : "";

    echo 
    $message
    And it produces nothing.

    PHP v4.0.6

    Any clues?
    John

  4. #4
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    On the second page you must call 'session_start()' first, it is only implicitly called when setting variables.

  5. #5
    Probably eating pie mitsubishi's Avatar
    Join Date
    Sep 2001
    Location
    England, UK
    Posts
    405
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Oh yeah and make sure that the session is started before any output, either by calling session_start() or setting the variable before output, once the session is started it doesnt matter when the variables are set.

  6. #6
    if($awake){code();} PHP John's Avatar
    Join Date
    Jul 2002
    Location
    Along the Wasatch Fault line.
    Posts
    1,771
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Mitsubishi,

    Thanks for your input.

    My local machine runs PHP v4.2.2.

    My host runs PHP v4.0.6.

    That is why I was asking if the $HTTP_SESSION_VARS[] worked on v4.0.6 because all of this works on my development machine, but not on my hsost.


    And I don't mean to be vague. I do have session_start();

    Let me post the relavant code:

    This is an include that goes at the head of all of my scripts for this site:
    PHP Code:
    <?php

        define
    ("INCPATH""e:/reviews/includes/"); // <- THIS IS CHANGED, OF COURSE, WHEN UPLOADED TO THE HOST
        
    include("sessions.inc");
        
    session_start();

        
    //    SERVER variables
        
    $PHP_SELF $HTTP_SERVER_VARS["PHP_SELF"];
        
    $REMOTE_ADDR $HTTP_SERVER_VARS["REMOTE_ADDR"];
        
    $REQUEST_URI $HTTP_SERVER_VARS["REQUEST_URI"];
        
    //    End SERVER variables
        
        
    $width 770;
        
    $hrWidth 450;
        
        
    $bottomNav "Y";
    ?>
    The above code is included in all the scripts at the TOP of the scripts.

    Then, I have another include at the end of the scripts:
    PHP Code:
    <?php

        
    // SESSION variables
        
    $message = isset($HTTP_SESSION_VARS["message"]) ? $HTTP_SESSION_VARS["message"] : "";
        
    // End SESSION variables
    ...

    echo 
    $message;
    ?>
    All of this works on my local machine, but not on my host...

    My host has "register_globals" on.

    Is there something else I should look for?
    Last edited by PHP John; Sep 6, 2002 at 13:31.
    John


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
  •