Re: setcookie
| From: | Jean-Christophe Roux | Date: | Wed, 12 Mar 2008 12:53:23 +0000 |
| Subject: | Re: setcookie | ||
| Groups: | php.general | ||
| Request: | Send a blank email to php-general+get-271348@lists.php.net to get a copy of this message | ||
> <body>
>
> <?php setcookie('test', 45, time()+(60*60*24*7)); ?>
from the doc:
"Cookies are part of the HTTP header, so setcookie() must be called before any output is sent
to the browser. This is the same limitation that header() has."
http://ca.php.net/cookies
----- Original Message ----
From: Tim Daff <timdaff@gmail.com>
To: php-general@lists.php.net
Sent: Wednesday, March 12, 2008 8:48:59 AM
Subject: [PHP] setcookie
Hi,
I am learning PHP, I am trying to set a simple cookie:
<html>
<head>
<title>Cookies</title>
</head>
<body>
<?php setcookie('test', 45, time()+(60*60*24*7)); ?>
</body>
</html>
Firefox is returning this error:
Warning: Cannot modify header information - headers already sent by
(output started at /Users/Daff/Sites/php_sandbox/cookies.php:7) in /
Users/Daff/Sites/php_sandbox/cookies.php on line 7
I have googled this and can't find out what I am doing wrong. Any
help you could give me would be much appreciated.
Tim
____________________________________________________________________________________
Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. Try it now. http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ