What might be the reason to get different values for session id in php?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Rinson Mathews
    New Member
    • Jan 2011
    • 5

    #1

    What might be the reason to get different values for session id in php?

    I am getting different session ids in these two pages,so that in the second page it is not identifying the session variable.

    I tried to execute the code given below
    My first page is:
    Code:
    <?php
    session_start();
    echo session_id();
    $_session["TstCycID"]='23';
    echo $_session["TstCycID"];
    ?>
    <BR><A HREF = "summary.php"> Execution Summary </A>
    Second page is:
    Code:
    <?php
     session_start();
     echo session_id();
     echo $_session["TstCycID"];
    ?>
    Last edited by Niheel; Feb 2 '11, 04:18 AM. Reason: Added [code] tags // updated so code tags showed two different pages / moved description to top
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Variables in PHP are case-sensitive. $_SESSION != $_session.

    Comment

    • Rinson Mathews
      New Member
      • Jan 2011
      • 5

      #3
      Thanks for your reply........
      But here I am using only small letters....

      Comment

      • Niheel
        Recognized Expert Moderator Top Contributor
        • Jul 2005
        • 2433

        #4
        What markus is trying to tell you is that you can't access the session variable by using

        $_session["TstCycID"];

        You have to use

        $_SESSION["TstCycID"];

        This is where session data is stored

        Because PHP variables are case sensitive $_session is not the same as $_SESSION.

        :)
        niheel @ bytes

        Comment

        • Rinson Mathews
          New Member
          • Jan 2011
          • 5

          #5
          Wow... the issue got resolved....... ....
          Thank you very much........

          Comment

          • Prakash Gnana
            New Member
            • Jan 2011
            • 25

            #6
            I agree with the answer of Niheel..

            Comment

            Working...