SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Enthusiast falfool's Avatar
    Join Date
    Jun 2003
    Location
    Amman
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Session Handling Problem! HELP MEEEE

    Hello all,
    I have Apache 1.3.7 and PHP 4.2.3, im facing a really big problem with Session Handling, whenever i start a session and register a variable to it i cant access that variable or change it or do anything with it, its like that Apache isnt recognizing the session .. check my code if im mistaken by anything:

    <?php

    session_start();

    session_register("username");

    $username = "Hello";

    echo "$username"; /* here will print "Hello" but in my session file it isnt assigned "Hello", its empty! */


    ?>


    Please help me , i think that its a problem in my php.ini config file, any help will be most appreciated . Thank You
    Ahmad Amireh

  2. #2
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    You've got things in the wrong order Also session_register shouldn't be used anymore.

    PHP Code:
    <?php
    session_start
    ();
     
    $username "Hello";
     
    $_SESSION['username'] = "Hello";
    ?>
    IIRC you can't access a variable until the next HTTP request - i.e. not on the same page as you set the variable. So echoing $_SESSION['username'] at this point would do nothing, it would need to be on a seperate page

    I think this is the case, correct me if I'm wrong.

    -Sam
    Sam Hastings

  3. #3
    SitePoint Enthusiast falfool's Avatar
    Join Date
    Jun 2003
    Location
    Amman
    Posts
    67
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    actually u r right, and before i check this reply, i had already found the solution now i use $_SESSION[] for every session variable, but thats somekinda confusing anyway, thanks alot for help

  4. #4
    SitePoint Wizard
    Join Date
    Mar 2002
    Location
    Bristol, UK
    Posts
    2,240
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not a problem Glad you got it sorted.

    -Sam
    Sam Hastings


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
  •