469,898 Members | 2,259 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,898 developers. It's quick & easy.

cookies

hi,

I have following problem.

I have a form wich I post to another php file there i want to store the data
form the form in a cookie.
code:

<?

foreach ($HTTP_POST_VARS as $key => $value) {

if($value=='ON')
{
setcookie("TestCookie","$key",time()+3600);

}

But it doens'n work. I have the following Error Warning: Cannot modify
header information - headers already sent by (output started at C:\Program
Files\Apache Group\Apache2

I understand the error and i have search in de tutorial form php.net, but
How can I handle this problem?

Thanks,

Alain


Jul 17 '05 #1
1 2250
Alain Dhaene wrote:
hi,

I have following problem.

I have a form wich I post to another php file there i want to store the data
form the form in a cookie.
code:

<?

foreach ($HTTP_POST_VARS as $key => $value) {

if($value=='ON')
{
setcookie("TestCookie","$key",time()+3600);

}

But it doens'n work. I have the following Error Warning: Cannot modify
header information - headers already sent by (output started at C:\Program
Files\Apache Group\Apache2

I understand the error and i have search in de tutorial form php.net, but
How can I handle this problem?

Thanks,

Alain


You must set cookies before sending any other output to the browser...
including spaces, line feeds, etc.

Move your code that does cookies to the top of your PHP file. Maybe
that'll help ya.

Regards,

- Dan
http://www.dantripp.com/
Jul 17 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

4 posts views Thread by Brian Burgess | last post: by
20 posts views Thread by Brian Burgess | last post: by
1 post views Thread by John Taylor-Johnston | last post: by
6 posts views Thread by Mark | last post: by
6 posts views Thread by Stephane | last post: by
1 post views Thread by Alex Nitulescu | last post: by
reply views Thread by rn5a | last post: by
reply views Thread by Salome Sato | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.