
January 4th, 2002
05:44 PM

Cookie header error
I always forget what causes this. something to do with exicuting html before the cookie is set. Heres the error:
Warning: Cannot add header information - headers already sent by (output started at d:\teen insomniac\site\ti.php:2) in d:\teen insomniac\site\pages\login.php on line 12
Warning: Cannot add header information - headers already sent by (output started at d:\teen insomniac\site\ti.php:2) in d:\teen insomniac\site\pages\login.php on line 13
Warning: Cannot add header information - headers already sent by (output started at d:\teen insomniac\site\ti.php:2) in d:\teen insomniac\site\pages\login.php on line 14
and the source:
<span class="font">
<?php
if($login=="yes") {
if(empty($userin) || empty($passin)) {
echo("<div align=\"center\">");
echo("<img src=\"template/images/error.gif\"><br>");
echo("<span class=\"font\">Sorry, you didn't complete the signin form. Try again</span>");
echo("</div>");
}else{
$vu=mysql_fetch_row(mysql_query("select admin_user,admin_pass from admin where admin_user=\"$userin\" and admin_pass=\"$passin\" LIMIT 1"));
if($vu[0]) {
SetCookie("tiadminuser","$vu[0]",Time()+180000);
SetCookie("tiadminpass","$vu[1]",Time()+180000);
header("location: $PHP_SELF?ti=admin");
}else{
include("pages/error401.php");
}
}
}else{
include("pages/loginform.php");
}
?>
</span>
___________________
Kyle Dreaden
<a href="http://www.deskmod.com">DeskMod Administrator</a>
<a href="mailto:dreden@deskmod.com">Dreden@DeskMod.com</a>
<i>It's coming...</i>

January 4th, 2002
07:25 PM
<?php
SetCookie("tiadminuser","$vu[0]",Time()+180000);
SetCookie("tiadminpass","$vu[1]",Time()+180000);
header("location: $PHP_SELF?ti=admin");
?>
That's your problem, specifically the header(). You cannot set a cookie then use the header() function.
___________________

http://metaeffect.com - Beyond the usual, as usual.

January 4th, 2002
07:34 PM
naw that didnt help, it just took away one of the lines of the error 
___________________
Kyle Dreaden
<a href="http://www.deskmod.com">DeskMod Administrator</a>
<a href="mailto:dreden@deskmod.com">Dreden@DeskMod.com</a>
<i>It's coming...</i>

January 4th, 2002
07:39 PM
Remove the first line, the <span> tag. See what happens! 
___________________

http://metaeffect.com - Beyond the usual, as usual.

January 4th, 2002
07:53 PM
add under <?php
ob_start("ob_gzhandler");

January 4th, 2002
08:01 PM
What's with the ob() functions?
___________________

http://metaeffect.com - Beyond the usual, as usual.

January 4th, 2002
08:08 PM
you can't have the <span class="font"> in there and have the Header(). i think its the same for the cookies but i'm not sure. i never use cookies.
___________________
Learn PHP.
Outburst Online

January 4th, 2002
09:30 PM
Maybe you figured this out already, but when u're using cookies u can not output any html before u set the cookies. Even a blank space in front of the <? can screw it up, it's just the way it works. So make sure you know that, you should probably check out the manual at php.net and read up on cookies, it'll give you ALOT of info.
___________________
<a href="http://www.toxicmusic.com"><img src="http://www.toxicmusic.com/brokenstar.gif" alt="Charlie Brown is the Coolest" border="0"></a>

January 4th, 2002
10:50 PM
http://www.php.net/manual/en/function.ob-start.php
output buffering.
so you can put stuff before setting cookies.

January 4th, 2002
10:52 PM
So I could, let's say, echo something before setting a cookie? 
___________________

http://metaeffect.com - Beyond the usual, as usual.