Page 2 of 2

Posted: Fri Mar 12, 2004 10:35 am
by johnperkins21
Dave, I tried your idea and got the following error:

PHP Warning: Cannot add header information - headers already sent by (output started at /tenyardfight/testcookie.php:3) in /tenyardfight/testcookie.php on line 4

I don't see how there are any headers being sent? I copied your code exactly as a test.

Posted: Fri Mar 12, 2004 10:39 am
by TheBentinel.com
johnperkins21 wrote:Dave, I tried your idea and got the following error:

PHP Warning: Cannot add header information - headers already sent by (output started at /tenyardfight/testcookie.php:3) in /tenyardfight/testcookie.php on line 4

I don't see how there are any headers being sent? I copied your code exactly as a test.
Duh, sorry John. Geesh, I need another coffee this morning.

Take out all the HTML before the <?php, so <?php is the first thing in the file.

(The cookies are sent in the header, but I had you output html code which goes AFTER the headers.)

Posted: Fri Mar 12, 2004 10:45 am
by johnperkins21
Yeah, I changed that part. Still not working.

Got rid of the error, but still not setting the cookie. Strange.

Posted: Fri Mar 12, 2004 10:49 am
by TheBentinel.com
johnperkins21 wrote: still not setting the cookie. Strange.
Try cutting out some of the optional stuff. I think all that's mandatory is the name and the value. Does this work?

Code: Select all

<?php
  setcookie("MyName", "MyValue");
?>

Posted: Fri Mar 12, 2004 10:56 am
by johnperkins21
Neato,
I got the cookie from your example to work by working my way back and adding each value one at a time. Then I took that code and copied it into my setcookie.php with no cookie being set and no error. Bummer. I'll keep working on it, but I appreciate you helping me with this.

Posted: Fri Mar 12, 2004 11:15 am
by johnperkins21
Dude, I played with it for about an hour or so, and I finally got it working.

I need to pass the variable to a separate page that just sets the cookie, but it seems to be working. Thanks for the help Dave.

Posted: Fri Mar 12, 2004 11:20 am
by TheBentinel.com
johnperkins21 wrote:Dude, I played with it for about an hour or so, and I finally got it working.
That's great, congrats!

[rant]
"So, how long will it take," asks the Boss. How do you estimate time acurately when it takes two days to put down a cookie! It's the dumb little stuff that eats up development time.
[/rant]

Posted: Sun Mar 14, 2004 10:50 am
by tim
isn't it funny how fixing a coding problem can easily steal hours away from the day. last night i spent about hour and 40 so mins working on a script that dealt with the dreaded regular expressions.

:roll:

Posted: Sun Mar 14, 2004 1:10 pm
by johnperkins21
And it almost always turns out to be something either easy or stupid. At least on my part, but I'm kind of dumb.

Posted: Sun Mar 14, 2004 1:19 pm
by tim
johnperkins21 wrote:I'm kind of dumb.
smart enough to solve your own problems.. most people just want to use this board to have the others code for them.
johnperkins21 wrote:And it almost always turns out to be something either easy or stupid
Yeah, a forgotten ";" a ) missing. Its those mistakes that make u a stronger coder when your in notepad(or whatever you use to code in) typing away. you'll see you'll make less n less as you learn more n more!

[/uncle_tom_talk]