Michael Purdy wrote:
Folks
I am running php 5.0.1 on NT.
I have a small test script as shown below
<script language="php">
setcookie('cat','large',time()+3600);
setcookie('dog','small',time()+3600);
</script>
The outcome of this script is that only the LAST cookie is successfully stored.despite
having a different
name. Is this because they are both being set from within the same script and
therefore conflicting with
each other?
Mike
First of all, use <?php and ?> instead of <script language="php"> and
</script>, the latter is not always supported. Second, are you sure that
you don't output any non-header information to the browser before
setting the cookies? Try using output buffering:
<?php
/* start output buffering */
ob_start();
/* print out something stupid (it is saved to the buffer) */
echo "mooo\n";
/* set them cookies */
setcookie("foo", "bar");
setcookie("bar", "foo");
/* it's getting even stupider (can you even say that?!) */
echo "baaah\n";
/* print the buffered output and end the output buffering */
ob_flush();
?>
Cheers,
Daniel
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php