Thread: Sessions\http

    #1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    win98/apache1.3.9/php4 rc1

    "Warning: Failed to write session data. Please check that the current setting of session.save_path is correct (/tmp) in Unknown on line 0"

    Does anyone know how i can fix this? I have the following in my php.ini

    session.save_handler = files ; handler used to store/retrieve data
    session.save_path = /tmp ; argument passed to save_handler
    ; in the case of files, this is the
    ; path where data files are stored
    session.use_cookies = 1 ; whether to use cookies
    session.name = PHPSESSID
    ; name of the session
    ; is used as cookie name

    etc...

    i tried changing session.save_path to a local directory but that doesn't seem to work?

    -----
    also... http_authentication doesn't work on my local machine. It keeps on giving me a 500 error and says it can't be displayed with the following code:

    if(!isset($PHP_AUTH_USER)) {
    Header("WWW-Authenticate: Basic realm="test"");
    Header("HTTP/1.0 401 Unauthorized");
    echo "cancel this!n";
    exit;
    } else {
    echo "Hello $PHP_AUTH_USER.<P>";
    echo "You entered $PHP_AUTH_PW as your password.<P>";
    }

    Is there something i need to turn on in my .conf files?

    any help would be greately appreciated =)

    Cisk
  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Mar 2000
    Posts
    60
    Rep Power
    15
    Okay, first problem. I'm flying by the seat of my Lugz here. Your php.ini is probably fine (identical to my win32 install). Try the following code. I just got through this problem, and I found an error in my code with the way I was registering sessions (they weren't registering, same "session.save_path" message). As for the second question, it won't work on Win32. All the reasons can be found all over this board with a search.

    <?php
    //Sessiontest.php4
    //From DevShed.
    session_start();
    // session variable to store the counter.
    session_register('counter');
    // session variable to store the value when the page was last loaded;
    // this value is maintained so that difference can be calculated.
    session_register('timeAtLastLoad');
    // current time
    $timeNow = time();
    // increment counter
    $counter++;
    // calculate the time lapsed from last visit.
    $timeLapsed = $timeNow - $timeAtLastLoad;
    // display appropriate message
    if($counter > 1)
    {
    echo "<b>It's been $timeLapsed seconds since you last viewed this page.</b>";
    }
    else
    {
    echo "<b>First time here? Reload this page to see how the session works!</b>";

    }
    $timeAtLastLoad = $timeNow;
    ?>
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    Thanks for the help but i keep getting this:

    First time here? Reload this page to see how the session works!
    Warning: Failed to write session data. Please check that the current setting of session.save_path is correct (/tmp) in Unknown on line 0

    I'm not sure what i'm doing wrong so i'll include the code thats in the file exactly.

    <?

    //Sessiontest.php4
    //From DevShed.
    session_start();
    // session variable to store the counter.
    session_register('counter');
    // session variable to store the value when the page was last loaded;
    // this value is maintained so that difference can be calculated.
    session_register('timeAtLastLoad');
    // current time
    $timeNow = time();
    // increment counter
    $counter++;
    // calculate the time lapsed from last visit.
    $timeLapsed = $timeNow - $timeAtLastLoad;
    // display appropriate message
    if($counter > 1)
    {
    echo "<b>It's been $timeLapsed seconds since you last viewed this page.</b>";
    }
    else
    {
    echo "<b>First time here? Reload this page to see how the session works!</b>";

    }
    $timeAtLastLoad = $timeNow;


    ?>

    that's all i have.. it should work no?

    Cisk
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    29
    Rep Power
    0
    I upgraded to PHPrc2 and now it works? hehe. I don't understand why but it works good now.

    Thanks anywayl

    Cisk

IMN logo majestic logo threadwatch logo seochat tools logo