?setcookie not function? - Programmers Heaven

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

?setcookie not function?

MaxLeeMaxLee Posts: 18Member
i know that the ssetcookies function should be called b4 any tags or other function, then i just do it so. but it display nothing but "setcookie("cuky_info","cuki_data",0,"","",0);" on the webpage.

Later on, i try the following code:
------------------------------------------------


<?php
ob_start();

setcookie("cuky_info","cuki_data",0,"","",0);

ob_end_flush();
?>

------------------------------------------------

but it display folowing error this time:

Warning: Cannot modify header information - headers already sent by (output started at C:Inetpubwwwroot risetcuki.php:3) in C:Inetpubwwwroot risetcuki.php on line 6

can anyone tell me whether it is due to my browser's setting or mistakes in my code. thx in advance.

Comments

  • DarQDarQ Posts: 1,625Member
    [red]
    you say yourself that it should be calle before any (HTML) tags or other output, then why do you use setcookie AFTER ob_start??? quite silly ;-)

    as you say it yourself, use setcookie as early as possible! so ABOVE ob_start() should do the trick.
    [/red]

    : i know that the ssetcookies function should be called b4 any tags or other function, then i just do it so. but it display nothing but "setcookie("cuky_info","cuki_data",0,"","",0);" on the webpage.
    :
    : Later on, i try the following code:
    : ------------------------------------------------
    :
    :
    : <?php
    : ob_start();
    :
    : setcookie("cuky_info","cuki_data",0,"","",0);
    :
    : ob_end_flush();
    : ?>
    :
    : ------------------------------------------------
    :
    : but it display folowing error this time:
    :
    : Warning: Cannot modify header information - headers already sent by (output started at C:Inetpubwwwroot risetcuki.php:3) in C:Inetpubwwwroot risetcuki.php on line 6
    :
    : can anyone tell me whether it is due to my browser's setting or mistakes in my code. thx in advance.
    :

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    NEW url--> http://mark.space.servehttp.com

  • netgertnetgert Posts: 331Member
    : [red]
    : you say yourself that it should be calle before any (HTML) tags or other output, then why do you use setcookie AFTER ob_start??? quite silly ;-)
    :
    : as you say it yourself, use setcookie as early as possible! so ABOVE ob_start() should do the trick.
    : [/red]

    using setCookie() after ob_start() is still ok but after html output ( tag is before <?php ?> tag) is very-very wrong

    :
    : : i know that the ssetcookies function should be called b4 any tags or other function, then i just do it so. but it display nothing but "setcookie("cuky_info","cuki_data",0,"","",0);" on the webpage.
    : :
    : : Later on, i try the following code:
    : : ------------------------------------------------
    : :
    : :
    : : <?php
    : : ob_start();
    : :
    : : setcookie("cuky_info","cuki_data",0,"","",0);
    : :
    : : ob_end_flush();
    : : ?>
    : :
    : : ------------------------------------------------
    : :
    : : but it display folowing error this time:
    : :
    : : Warning: Cannot modify header information - headers already sent by (output started at C:Inetpubwwwroot risetcuki.php:3) in C:Inetpubwwwroot risetcuki.php on line 6
    : :
    : : can anyone tell me whether it is due to my browser's setting or mistakes in my code. thx in advance.
    : :
    :
    : [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    : NEW url--> http://mark.space.servehttp.com
    :
    :

    [hr][red][italic][b]N[/b][/red][blue]et[/blue][red][b]G[/b][/red][blue]ert[/italic][/blue][hr]

  • DarQDarQ Posts: 1,625Member
    [b][red]This message was edited by Moderator at 2004-1-10 12:0:18[/red][/b][hr]
    [red]
    bah, you're right, i'm wrong! how could i....;-)
    [/red]
    : using setCookie() after ob_start() is still ok but after html output ( tag is before <?php ?> tag) is very-very wrong

    [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    NEW url--> http://mark.space.servehttp.com



  • MaxLeeMaxLee Posts: 18Member
    : [b][red]This message was edited by Moderator at 2004-1-10 12:0:18[/red][/b][hr]
    : [red]
    : bah, you're right, i'm wrong! how could i....;-)
    : [/red]
    : : using setCookie() after ob_start() is still ok but after html output ( tag is before <?php ?> tag) is very-very wrong
    :
    : [size=5][italic][blue]Dar[RED]Q[/RED][/blue][/italic][/size]
    : NEW url--> http://mark.space.servehttp.com
    :
    :
    :
    :
    great.i solved the problem already. Thx u guys help!!
Sign In or Register to comment.