#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    NY, NY,USA
    Posts
    18
    Rep Power
    0
    I am not having any trouble setting a cookie, but am having trouble reading the cookie from another page. Could someone tell me what I'm doing wrong here? The first page sets the cookie the second page is supposed to read the cookie and say that it worked.

    Thanks
    --------------------------
    index.php3 follows:

    <?php
    setcookie("flashtest","1");
    ?>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">

    <html>
    <head>
    <title>Untitled</title>
    </head>

    <body>
    <?php print $flashtest; ?>

    <a href="second.php3">Next</a>

    </body>
    </html>


    second.php3 follows:
    <?php
    if (isset($testcookie)){
    ?>
    <HTML>
    <HEAD><TITLE>It worked</TITLE>
    </HEAD>
    <BODY>

    <H1>It worked</H1>
    <?php
    print $testcookie;
    }
    else { ?>
    <HTML>
    <HEAD>
    <TITLE>It didn't work</TITLE>
    </HEAD>
    <BODY>
    <H1>It didn't work</H1>
    <?php print $testcookie; } ?>
    </BODY>
    </HTML>


  2. #2
  3. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    7
    Rep Power
    0
    brett_webb,

    <notice>I could be completely wrong because I'm new to PHP also</notice>

    Could the reason you can't read the cookie be because you aren't calling it by the same name that you set it with.

    Try:

    <?php
    if (isset($flashtest)){
    ?>

    That should work, I think. If not, go to http://www.php.net/manual/html/function.setcookie.html to solve your problems.

    John


  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Feb 2000
    Location
    NY, NY,USA
    Posts
    18
    Rep Power
    0
    So it's been a long week and I'm losing it. Thanks for pointing out that idiocy on my part.
  6. #4
  7. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Jun 2000
    Posts
    7
    Rep Power
    0
    No problem. I've asked so many questions in forums, it's about time I could answer a few!

    John

Similar Threads

  1. Placing user-entered data into cookie
    By Tyrone in forum Perl Programming
    Replies: 2
    Last Post: February 17th, 2004, 05:31 PM
  2. Session Cookie Problem?
    By JHarp in forum PHP Development
    Replies: 1
    Last Post: February 17th, 2004, 02:43 PM
  3. re: Cookie - serves only one directory?
    By ellen in forum PHP Development
    Replies: 1
    Last Post: February 17th, 2004, 12:59 AM
  4. Odd COOKIE problem
    By rwreid in forum PHP Development
    Replies: 3
    Last Post: January 28th, 2004, 02:43 AM
  5. Problem reading binary files
    By dutd33 in forum C Programming
    Replies: 3
    Last Post: January 26th, 2004, 07:55 AM

IMN logo majestic logo threadwatch logo seochat tools logo