SitePoint Sponsor

User Tag List

Results 1 to 6 of 6

Thread: Session Problem

  1. #1
    SitePoint Enthusiast moekilla's Avatar
    Join Date
    Jul 2001
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Angry Session Problem

    Hi! I just installed php in my computer. And i can't get session objects to work. I've coded all syntax to make the session but still nothing's there.
    PHP Code:
    <?php
    //test.php
    session_start();
    $_SESSION["key1"] = "testvalue";
    header("Location: test2.php");
    ?>
    PHP Code:
    <?php
    //test2.php
    session_start();
    echo 
    "key1 = '"$_SESSION["key1"] ."'";
    echo 
    phpinfo();
    ?>
    the code snippet above is a simple example i took from php.net. but it doesn't work. I already configured the php.ini file to the one suggested in php.net but still doesn't work.

    Need help! Thanks.

  2. #2
    SitePoint Zealot
    Join Date
    Aug 2003
    Location
    everywhere
    Posts
    179
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Hmm weird that. Are you recieving any errors or is it just not showing up

  3. #3
    SitePoint Addict moonchild's Avatar
    Join Date
    Nov 2003
    Location
    U$A
    Posts
    258
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    put this at the top of your scripts, and see if any errors get printed.

    PHP Code:
    <?php
    // Set Error Reporting
         
    error_reporting(E_ALL);
    ?>
    if anything is generating an error, this will show it.

  4. #4
    PHP manual bot bronze trophy Gaheris's Avatar
    Join Date
    Oct 2003
    Location
    Germany
    Posts
    2,195
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    What PHP version do you have?

  5. #5
    SitePoint Enthusiast DaveCheney's Avatar
    Join Date
    Dec 2003
    Location
    Melbourne, Australia
    Posts
    66
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    By default PHP will put your session data into a file in your nominated temporary directory

    On *nix this is /tmp, on windows it might be /windows/temp, so check your php.ini

    The file has the same name as your session id, which you can check from print( session_id() );

    Have a look in the session file for your current session and you can see any data written there from your script.

    Apart from that my only suggestion would be accessing your array index via the ' operator, not the ". This has caused problems for me in the past.

    Cheers

    Dave

  6. #6
    SitePoint Enthusiast moekilla's Avatar
    Join Date
    Jul 2001
    Posts
    33
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    php 4.3.4

    This is the version of my PHP. I also set the display_error to On and also the error_reporting was defaulted to E_ALL. I set the folder to "C:\windows\temp" already. It doesn't give me an error when i attempt to print the session variable i put but it just gives me a blank page. no error too. It does have a session_id() though when i print it. I dont understand. It's suppose to work. Help! Thanks....


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
  •