PDA

View Full Version : PHP cookies


Rain Designs
02-26-2003, 07:30 PM
I'm having trouble setting a cookie and accessing that cookie. to set the cookie I used this...

setcookie("status", "loggedin", time()+43200, "/", "lswineman.com", 0);

and I got this...

Warning: Cannot modify header information - headers already sent by

any ideas?

Thanks

Rain

Gregory
02-26-2003, 07:34 PM
sorry, the only thing i can do in php is:
print("HEY")
but i never get to test it cuz my host doesnt support PHP

Rain Designs
02-26-2003, 08:57 PM
hehe :D

You should learn php! Its not that bad

Rain

BTW - Thanks anyway

yoda
02-27-2003, 04:32 AM
the setcookie() function should be at the very top of the page before anything else is outputted on the page. so no echo's print's or any html before you use the setcookie() function. not even a blank line before your <?php tag.
im sure some other can explain it mroe sphistacated

scoutt
02-27-2003, 09:33 AM
yoda is correct. you have to have the setcookie at teh very top before any html is outputted to the screen. this includes any html tags and any php echo's or prints.

Rain Designs
02-27-2003, 11:04 AM
can I have other php lines above the setcookie? like:

if (blah)
setcookie();

Thanks for the help

Rain

scoutt
02-27-2003, 11:20 AM
yes you can, you just can't echo anything