session management

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • bikashliju
    New Member
    • Sep 2010
    • 9

    session management

    i have two programmes

    FORM.PHP
    Code:
    <?PHP
    session_start();
    ?>
    <html>
    <body>
    <form action="welcome.php" method="post">
    firstname: <input type="text" name="fname" />
    <input type="submit" />
    </form>
    
    </body>
    </html>
    WELCOME.PHP
    Code:
    <?php
    session_start();
    
    if($_COOKIE[' PHPSESSID']=$_SESSION['PHPSESSID'])
    {
     echo  $_POST["fname"];
    }
    else
    {
    echo"wrong session id";
    }
    ?>
    but it gives me output wrong session id.
    Code:
    ($_COOKIE[' PHPSESSID']=$_SESSION['PHPSESSID'])
    i want to know whether this is a true condition or not , kindly inform if any syntactical error in it
    Last edited by Dormilich; Oct 12 '10, 08:43 AM.
  • dlite922
    Recognized Expert Top Contributor
    • Dec 2007
    • 1586

    #2
    First of all you have a space in the cookie name.

    Second you're not doing a comparison, you're doing an assignment with a single equal sign. To compare the two and return true or false you need two (2) equal signs.

    This will test if the value of $foo equals the value of $bar:

    $bar == $foo

    This will put the value of $foo in to $bar so that they they contain the same value:

    $bar = $foo

    Let us know if that fixed it,



    Dan

    Comment

    • bikashliju
      New Member
      • Sep 2010
      • 9

      #3
      thanx sir
      u solved my problem ....

      Comment

      Working...