PHP cookies

admin

Administrator
Staff member
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

Rainsorry, the only thing i can do in php is:
print("HEY")
but i never get to test it cuz my host doesnt support PHPhehe :D

You should learn php! Its not that bad

Rain

BTW - Thanks anywaythe 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 sphistacatedyoda 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.can I have other php lines above the setcookie? like:

if (blah)
setcookie();

Thanks for the help

Rainyes you can, you just can't echo anything
 
Back
Top