Banner

Sponsor

Login


Welcome Back!
Guest
Guest

Register

Lost your password?

57 users online



Cookie header error

Cookie header error

Currently viewing this thread: 1 (0 members and 1 guests)


Page 1 out of 2
Dreden

Dreden

Status: Offline!

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:

PHP:


<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>

metabolite

metabolite

Status: Offline!
PHP:

<?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://www.metaeffect.com/imgs/links/m4btn.jpg http://www.metaeffect.com/imgs/links/m4btn2.jpg
http://metaeffect.com - Beyond the usual, as usual.

Dreden

Dreden

Status: Offline!

naw that didnt help, it just took away one of the lines of the error Sad

___________________

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>

metabolite

metabolite

Status: Offline!

Remove the first line, the <span> tag. See what happens! Smile

___________________

http://www.metaeffect.com/imgs/links/m4btn.jpg http://www.metaeffect.com/imgs/links/m4btn2.jpg
http://metaeffect.com - Beyond the usual, as usual.

Guest

Guest

Anonymous Coward

add under <?php
ob_start("ob_gzhandler");

metabolite

metabolite

Status: Offline!

What's with the ob() functions?

___________________

http://www.metaeffect.com/imgs/links/m4btn.jpg http://www.metaeffect.com/imgs/links/m4btn2.jpg
http://metaeffect.com - Beyond the usual, as usual.

Trav

Trav

Status: Offline!

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

TwoWeekEternity

TwoWeekEternity

Status: Offline!

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>

Guest

Guest

Anonymous Coward

http://www.php.net/manual/en/function.ob-start.php

output buffering.
so you can put stuff before setting cookies.

metabolite

metabolite

Status: Offline!

So I could, let's say, echo something before setting a cookie? Smile

___________________

http://www.metaeffect.com/imgs/links/m4btn.jpg http://www.metaeffect.com/imgs/links/m4btn2.jpg
http://metaeffect.com - Beyond the usual, as usual.

Page 1 out of 2
Quick Jump:

Main Navigation


Site & Graphic Design by Aeon Tan
Developed by Jeremie Pelletier & Scott Roach


NeverAPI generated this page in 0.0099 seconds.