php session problem

Discussion in 'PHP' started by bhavin123000, Jul 9, 2007.

  1. #1
    Hi
    I Am Little New To Php
    I Am Having Some Problem Regarding The Session In Php.
    Here Is My Problem.

    As Like All Website My Aim Is To Ask For Id And Password From User And After Checking The Id And Password I Create One Session And Store User Id In One Variable To Refer To Other Page.
    And I Am Redirecting To Home Page After Setting Session And At That Home Page I Am Unable To Retrieve That Session Variable Data.
    Means My Session Is Not Persistence.

    Can Anyone Help Me

    Waiting For Reply.
    If Code Require Ask Me


    I Am Doing This On Server Lot Local Server
     
    bhavin123000, Jul 9, 2007 IP
  2. ansi

    ansi Well-Known Member

    Messages:
    1,483
    Likes Received:
    65
    Best Answers:
    0
    Trophy Points:
    100
    #2
    page 1:
    
    <?php
        session_start();
        $_SESSION['foo'] = "bar";
    ?>
    <a href="page2.php">goto page 2</a>
    
    PHP:
    page 2:
    
    <?php
        session_start();
        echo $_SESSION['foo'];
    ?>
    
    PHP:
     
    ansi, Jul 9, 2007 IP
  3. technoguy

    technoguy Notable Member

    Messages:
    4,385
    Likes Received:
    308
    Best Answers:
    0
    Trophy Points:
    205
    #3
    can you paste yoru code here? So i can have a look at it.
     
    technoguy, Jul 9, 2007 IP
  4. pfek

    pfek Member

    Messages:
    98
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    45
    #4
    Your problem must have been in the omitance of the session_start() function, which is necessary to save and use Session Variables.
     
    pfek, Jul 9, 2007 IP