PHP

Moderators: None (Apply to moderate this forum)
Number of threads: 1848
Number of posts: 5016

This Forum Only
Post New Thread
Single Post View       Linear View       Threaded View      f

Report
?setcookie not function? Posted by MaxLee on 9 Jan 2004 at 2:43 AM
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:
------------------------------------------------
<html>

<?php
ob_start();

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

ob_end_flush();
?>
</html>
------------------------------------------------

but it display folowing error this time:

Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\tri\setcuki.php:3) in C:\Inetpub\wwwroot\tri\setcuki.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.
Report
Re: ?setcookie not function? Posted by DarQ on 9 Jan 2004 at 4:21 AM

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.


: 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:
: ------------------------------------------------
: <html>
:
: <?php
: ob_start();
:
: setcookie("cuky_info","cuki_data",0,"","",0);
:
: ob_end_flush();
: ?>
: </html>
: ------------------------------------------------
:
: but it display folowing error this time:
:
: Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\tri\setcuki.php:3) in C:\Inetpub\wwwroot\tri\setcuki.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.
:

DarQ
NEW url--> http://mark.space.servehttp.com

Report
Re: ?setcookie not function? Posted by netgert on 10 Jan 2004 at 11:29 AM
:
: 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.
:


using setCookie() after ob_start() is still ok but after html output (<html> 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:
: : ------------------------------------------------
: : <html>
: :
: : <?php
: : ob_start();
: :
: : setcookie("cuky_info","cuki_data",0,"","",0);
: :
: : ob_end_flush();
: : ?>
: : </html>
: : ------------------------------------------------
: :
: : but it display folowing error this time:
: :
: : Warning: Cannot modify header information - headers already sent by (output started at C:\Inetpub\wwwroot\tri\setcuki.php:3) in C:\Inetpub\wwwroot\tri\setcuki.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.
: :
:
: DarQ
: NEW url--> http://mark.space.servehttp.com
:
:


NetGert[/italic]


Report
Re: ?setcookie not function? Posted by DarQ on 10 Jan 2004 at 12:00 PM
This message was edited by Moderator at 2004-1-10 12:0:18


bah, you're right, i'm wrong! how could i....

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

DarQ
NEW url--> http://mark.space.servehttp.com



Report
Re: ?setcookie not function? Posted by MaxLee on 11 Jan 2004 at 9:18 PM
: This message was edited by Moderator at 2004-1-10 12:0:18

:
: bah, you're right, i'm wrong! how could i....
:

: : using setCookie() after ob_start() is still ok but after html output (<html> tag is before <?php ?> tag) is very-very wrong
:
: DarQ
: NEW url--> http://mark.space.servehttp.com
:
:
:
:
great.i solved the problem already. Thx u guys help!!



 

Recent Jobs

Official Programmer's Heaven Blogs
Web Hosting | Browser and Social Games | Gadgets

Popular resources on Programmersheaven.com
Assembly | Basic | C | C# | C++ | Delphi | Flash | Java | JavaScript | Pascal | Perl | PHP | Python | Ruby | Visual Basic
© Copyright 2011 Programmersheaven.com - All rights reserved.
Reproduction in whole or in part, in any form or medium without express written permission is prohibited.
Violators of this policy may be subject to legal action. Please read our Terms Of Use and Privacy Statement for more information.
Operated by CommunityHeaven, a BootstrapLabs company.