php session doesn't work

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jansi1975
    New Member
    • Dec 2009
    • 1

    php session doesn't work

    My scripts have been working since past 3 years. But now recently the page doesn''t work well. The page is working well under php4 in localhost but in the server side this seems to be error. on the server side our server switch over to php4 to php5 version. even the simple page is also doesn't work.

    I checked whether the error in Javascript and other think so but i couldn't catch it. I have been created the simple page with Jscript. Its work nice. But without session creation the page is working. It seems the error occurs in session in my php.

    This source code working under php4 version fine. But in the php5 doesn't work.


    Code:
    if(isset($_POST['submit']))  
      {  
     session_start(); 
     $_SESSION['id'] = 'AAAA';
     echo "The Session Value is = $id <br></br>";
     } else { 
     echo "<br> <br> Retrieve No Submitted";  
     } 
    ?>
     
       <form name = "form" method  = "POST" action = "sess.php">
     
              <input id="submit" name="submit" type="submit" value="Session" />  
        <br><br>
    Last edited by Dormilich; Dec 15 '09, 06:57 AM. Reason: Please use [code] tags when posting code
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    where does $id on line #5 come from? from PHP 5, security settings are made so, that you can’t access $_POST['name'] ($_GET, $_REQUEST, etc.) as $name without previous conversion.

    Comment

    • Atli
      Recognized Expert Expert
      • Nov 2006
      • 5062

      #3
      See Using Register Globals for more info on what Dormilich is talking about.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        in general it is recommended to always access $_SESSION['id'] as such.

        Code:
        $_SESSION['id'] = "AAA";
        // …
        echo $_SESSION['id'];
        it may well be that you later access your session variables in a different way by calling the index
        e.g.
        Code:
        // you could for instance write a session handling class:
        echo $session->mySessionVarName;

        Comment

        Working...