FRIHOST FORUMS SEARCH FAQ TOS BLOGS COMPETITIONS
You are invited to Log in or Register a free Frihost Account!


HELP: setcookie() and header problems





AnGeLicK
i keep on getting the following error when i use setcookie()... i surround it with ob_start() and ob_end_flush().

Warning: Cannot modify header information - headers already sent by (output started at /home/*****/public_html/livesets.php:11) in /home/*****/public_html/livesets.php on line 35
neaf2003
you can add tis code to your script to anable output buffer
Code:

ob_start("ob_gzhandler");
the666bbq
this is a very common error when using cookies. What happened is that you try to do something on the clients computer (set cookie) where you already made the roundtrip back to the server and try to write something to the new page for the client. There are two ways of handling these kinds of problems :

a) avoid/make sure that you have no output send to the client before al your cookie stuff (no echo, no print, not even spaces before your php code,...)

b) use javascript to handle the cookies. The javascript will only work on client side, so no problems with headers already sent (meaning page has left the server building)
Related topics
Reply to topic    Frihost Forum Index -> Scripting -> Php and MySQL

FRIHOST HOME | FAQ | TOS | ABOUT US | CONTACT US | SITE MAP
© 2005-2011 Frihost, forums powered by phpBB.