Two servers, two different results with session variables?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • museumoftechno
    New Member
    • Jul 2007
    • 3

    Two servers, two different results with session variables?

    Hello

    I'm new to PHP session variables, and I'm doing some work for a client whose website uses session variables in a form that contains image verification. There's a problem with the form - it appears that a session variable is being forgotten. So I wrote this quick test script to investigate:

    Code:
    $html = "Pre session start - myvalue = " . $_SESSION['myvalue'] . "<br /><br />";
    session_start();
    $html .= "Post session start - myvalue = " . $_SESSION['myvalue'] . "<br /><br />";
    $_SESSION['myvalue'] = str_shuffle('abcdefg');
    $html .= "Just set myvalue = " . $_SESSION['myvalue'] . "<br /><br />";
    echo $html;
    Now, on my own website, each time I refresh the page, the code at line 1 prints an empty value (as expected); the code at line 3 prints the session variable set the previous time I viewed the page; and the code at line 5 prints the value of the session variable set this time round.

    On my client's server, though, line 3 always returns an empty value - as if the session variable, or the whole session, is being forgotten between page refreshes. Apologies if this is a stupid question, but can anyone give me any pointers as to what might have changed recently on my client's server to have caused this problem?

    Many thanks

    Dave
  • pbmods
    Recognized Expert Expert
    • Apr 2007
    • 5821

    #2
    Heya, Dave. Welcome to TSDN!

    If your code doesn't change, but the results do, check the php.ini file on each server. You might have incorrect cookie settings, for example, that might cause session info not to get saved.

    Comment

    • museumoftechno
      New Member
      • Jul 2007
      • 3

      #3
      Originally posted by pbmods
      Heya, Dave. Welcome to TSDN!

      If your code doesn't change, but the results do, check the php.ini file on each server. You might have incorrect cookie settings, for example, that might cause session info not to get saved.
      I've emailed the guys responsible for the server, we'll see what they say. Thanks for the hint, and well done for the forum!

      Dave

      Comment

      • museumoftechno
        New Member
        • Jul 2007
        • 3

        #4
        Originally posted by museumoftechno
        I've emailed the guys responsible for the server, we'll see what they say.
        ...And in fact it was the aftermath of some changes made to permissions on the server, which I didn't know about. Sorry to waste your time guys, but thanks again for the response, you helped me ask some useful questions. Have a good weekend...

        D

        Comment

        • pbmods
          Recognized Expert Expert
          • Apr 2007
          • 5821

          #5
          Heya, Dave.

          Glad to hear you got it working! Good luck with your project, and if you ever need anything, post back anytime :)

          Comment

          Working...