By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
437,751 Members | 1,149 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 437,751 IT Pros & Developers. It's quick & easy.

cookies

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.