Cookies and Variables
| From: | Richard S. Crawford | Date: | Tue, 20 Nov 2001 20:59:46 +0000 |
| Subject: | Cookies and Variables | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-75285@lists.php.net to get a copy of this message | ||
Consider this code, in page1.php:
<?php
setcookie("someWord","I am a cookie");
?>
...and this code, in page2.php:
<?php
setcookie("someWord",$someWord);
print ("someWord says: $someWord");
$someWord = "I am a variable";
print ("< a href=\"page2.php?someWord=$someWord\" >Click here< /a >");
?>
(In the actual code, the value of $someWord is passed via POST through a form, but the principle is the same.)
The first time I load page2.php, the output should be:
someWord says: I am a cookieWhich, of course, works perfectly. But each subsequent time I load page2.php, I want the output to be:
someWord says: I am a variableand then set the value of the cookie "someWord" to "I am a variable". But that's not what happens. Everytime I load page2.php, someWord tells me that it is a cookie. How do I get the value of the variable to override the value of the cookie? Sliante, Richard S. Crawford http://www.mossroot.com AIM: Buffalo2K ICQ: 11646404 Y!: rscrawford MSN: underpope@hotmail.com "It is only with the heart that we see rightly; what is essential is invisible to the eye." --Antoine de Saint Exupéry "Push the button, Max!"