|
-
Jul 29th, 2002, 12:15 AM
#1
Thread Starter
Fanatic Member
Cookies
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 29th, 2002, 02:03 AM
#2
-
Jul 29th, 2002, 06:58 AM
#3
Fanatic Member
To sum up what ubunreal69 said a bit clearer..
A cookie has to be set before any output of any kind is made. This includes html, javascript, php echo or print statements, etc.
Example (these will not work):
PHP Code:
<html>
<?php setcookie("","","","",""); ?>
PHP Code:
<?php
echo "Text";
setcookie("","","","","");
?>
Example (these will work):
PHP Code:
<?php setcookie("","","","",""); ?>
<html>
PHP Code:
<?php
setcookie("","","","","");
echo "Text";
?>
-
Jul 29th, 2002, 07:44 AM
#4
Fanatic Member
How would you see if a cookie existed?
-
Jul 29th, 2002, 07:44 AM
#5
Frenzied Member
Re: Cookies
Originally posted by prog_tom
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php:8) in /home/tom/sviesoft/login/login.php on line 1000099238
what is wrong?
show us the code?
-
Jul 29th, 2002, 07:59 AM
#6
Fanatic Member
Originally posted by Gimlin
How would you see if a cookie existed?
PHP Code:
if (isset($_COOKIE['variable name']))
echo "The cookie exists with the value of ".$_COOKIE['variable name'];
else
echo "The cookie does not exist."
-
Jul 29th, 2002, 08:13 AM
#7
-
Jul 29th, 2002, 10:06 AM
#8
Thread Starter
Fanatic Member
I tried:
PHP Code:
<?setcookie("myage","12",time()+600);print "$myage";?>
doesn't work.
you may view this file at
http://www.sviesoft.com/beta/cookie.php

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 29th, 2002, 10:12 AM
#9
Fanatic Member
you should always set as the path and domain portions of the cookie.
PHP Code:
<?php
setcookie("myage","12",time()+600,"/",$_SERVER['HTTP_HOST']);
if (!isset($_COOKIE['myage']))
echo "Please Refresh the page.";
else
echo $_COOKIE['myage'];
?>
Viewable at http://cpradio.net/cookieTest.php
Source Code: http://cpradio.net/cookieTest.phps
Last edited by cpradio; Jul 29th, 2002 at 10:18 AM.
-
Jul 29th, 2002, 10:16 AM
#10
Frenzied Member
we need to see the whole page.
-
Jul 29th, 2002, 10:16 AM
#11
Fanatic Member
Originally posted by phpman
we need to see the whole page.
No we don't
-
Jul 29th, 2002, 11:45 AM
#12
Stuck in the 80s
Originally posted by prog_tom
I tried:
PHP Code:
<?setcookie("myage","12",time()+600);print "$myage";?>
Just a few quick notes:
- According to standards, you should always use "<?php" instead of "<?" You should also never put more than one statement on one line.
- Cookies should be displayed as "$_COOKIE["myage"]" for 4.2 compatability.
- And finally: "Cookies will not become visible until the next loading of a page that the cookie should be visible for." So printing "$myage" would not work until you refreshed.
Matt already covered most of these, but I thought I'd buzz in anyways.
-
Jul 29th, 2002, 11:49 AM
#13
Frenzied Member
Originally posted by cpradio
No we don't
well I thought he was still getting the error. 
but it seems that you have taken care of Tom.
-
Jul 29th, 2002, 11:52 AM
#14
Stuck in the 80s
Originally posted by phpman
well I thought he was still getting the error. 
but it seems that you have taken care of Tom.
It's a very common error, that's why we didn't need to see code.
-
Jul 29th, 2002, 11:59 AM
#15
Frenzied Member
really, so where was the error?
and tell me if this will produce a header error
PHP Code:
<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
that is one file by the way.
-
Jul 29th, 2002, 11:59 AM
#16
Fanatic Member
I love the redundant questions in life
-
Jul 29th, 2002, 12:06 PM
#17
Fanatic Member
Originally posted by phpman
really, so where was the error?
and tell me if this will produce a header error
PHP Code:
<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
that is one file by the way.
This will produce an error, as white space has been created above the setcookie function. PHP only ignores white space inbetween the <?php ?> tagsand this white space was created by the file/html/whatever. (sounds redundant doesn't it )
Now you can use either of the below instead of what is written above:
PHP Code:
<?php
$var = "hello";
?>
<?php
setcookie("","","","","");
?>
PHP Code:
<?php
$var = "hello";
setcookie("","","","","");
?>
Last edited by cpradio; Jul 29th, 2002 at 12:10 PM.
-
Jul 29th, 2002, 12:14 PM
#18
Frenzied Member
yes, you are correct Matt, but I was just curious as to how you knew it was something being echoed or just white space. if he was new to this then he would say there is nothing that is being echoed. but it seems that he was talking to somebody behind the scences.
yes it would produce an error and no newbie would now that.
even if he included a file before the setcookie like the code I gave it would produce the same error. that is why I said to show us the code.
in /home/tom/sviesoft/login/login.php on line 1000099238
100009238+ lines of code?????????? yeah right. I never seen file with that many lines of code.
-
Jul 29th, 2002, 12:18 PM
#19
Fanatic Member
point made
-
Jul 29th, 2002, 12:48 PM
#20
Stuck in the 80s
I just thought it'd be easier to tell him what was up, then have him post code and point out the individual mistakes.
And just incase anyone cares, it's raining all around my house except in my back yard. Imma go watch it.
-
Jul 29th, 2002, 04:40 PM
#21
Thread Starter
Fanatic Member
100009238+ lines of code?????????? yeah right. I never seen file with that many lines of code.
That's because most low-level never seen it. Thus you may be one of them.
this cookie **** is driving me insane.
check out:
http://www.sviesoft.com/beta/1.php
PHP Code:
<?setcookie("yonghuming","prog_tom",NULL,"","sviesoft.com");
if(isset($yonghuming)){print $yonghuming;}?>
everytime I make expiration to time()+600, it just doesn't work, seems like PHP on my server either didn't set up correctly, or it doesn't support time(). It doesn't support $_COOKIES or other crap either, if I use $_COOKIES it gives me $T_VAR or some crap error.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 29th, 2002, 04:54 PM
#22
Frenzied Member
That's because most low-level never seen it. Thus you may be one of them.
bull**** Tom, don't give me that. even professional programmers don't have pages that long. and you call yourself a high-level programmer? you can't even get a cookie right......
I can almost bet you didn't write it either. let me see the file if it has that many lines in it.....
<?
setcookie("yonghuming","prog_tom", time() +600,"","sviesoft.com");
if(isset($yonghuming)){print $yonghuming;}?>
-
Jul 29th, 2002, 05:02 PM
#23
Thread Starter
Fanatic Member
Did I mention anything as a programmer myself? I wish, someday, to become one, but first I gotta learn from you.
PHP Code:
setcookie("yonghuming","prog_tom",0,"/","",0);
that seems working, but how long do 0 last? forever?

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 29th, 2002, 05:06 PM
#24
Frenzied Member
no cookie can last forever. al you can do is make it last a year I think.
I think if you set it at 0 then it will go away when the browser is closed.
just set time() +43200
setcookie("yonghuming","prog_tom", time() +43200 );
-
Jul 29th, 2002, 05:33 PM
#25
Stuck in the 80s
Originally posted by phpman
no cookie can last forever. al you can do is make it last a year I think.
I think if you set it at 0 then it will go away when the browser is closed.
just set time() +43200
setcookie("yonghuming","prog_tom", time() +43200 );
Yeah, cookies always expire, although I think you can make them longer than a year. And yes, it'll expire when the browser closes if it's set to 0.
My suggestion: set it for a year and renew it each time the user comes to the page.
-
Jul 29th, 2002, 05:37 PM
#26
Stuck in the 80s
Originally posted by phpman
bull**** Tom, don't give me that. even professional programmers don't have pages that long.
I have to agree there. 100 million lines (100,009,238) of code is way, way beyond absurd...
-
Jul 30th, 2002, 05:00 PM
#27
Thread Starter
Fanatic Member
the file is nearly 1.3 TB.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
-
Jul 30th, 2002, 05:03 PM
#28
Frenzied Member
yeah and my dick is 5 miles long,
give me a break Tom
-
Jul 30th, 2002, 05:03 PM
#29
Stuck in the 80s
Originally posted by prog_tom
the file is nearly 1.3 TB.
hmm...how do you fit that on a 120 gig hard drive?
-
Jul 30th, 2002, 06:35 PM
#30
Fanatic Member
Yah? and what does it do Tom
-
Jul 30th, 2002, 07:22 PM
#31
Stuck in the 80s
Re: Cookies
Originally posted by prog_tom
Warning: Cannot add header information - headers already sent by (output started at /home/tom/sviesoft/login/login.php: 8) in /home/tom/sviesoft/login/login.php on line 100009923 8
what is wrong?
hmmm...does tommy lie alot?
-
Jul 30th, 2002, 07:22 PM
#32
Fanatic Member
prog_tom, are you sure the server even supports cookies ? try a simple bit of code to just test it first.
simple test:
PHP Code:
setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
-
Jul 30th, 2002, 08:31 PM
#33
Fanatic Member
Re: Re: Cookies
Originally posted by The Hobo
hmmm...does tommy lie alot?
Good catch
-
Jul 30th, 2002, 09:38 PM
#34
Stuck in the 80s
Originally posted by ubunreal69
prog_tom, are you sure the server even supports cookies ? try a simple bit of code to just test it first.
simple test:
PHP Code:
setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
That won't work. Cookies aren't accessable until it is reloaded. Cookies won't appear until the script that set them is refreshed.
-
Jul 31st, 2002, 04:49 AM
#35
Fanatic Member
Originally posted by The Hobo
That won't work. Cookies aren't accessable until it is reloaded. Cookies won't appear until the script that set them is refreshed.
let me re-phrase it then 
put:
PHP Code:
setcookie("greeting","elooo", time()+3600);
IF (isset($_COOKIE['greeting']))
{ECHO 'cookie value is', $_COOKIE['greeting'];}
run the page, then refresh it.
-
Jul 31st, 2002, 06:09 PM
#36
Lively Member
A new line for each statement?!
Yo! My first post...
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
I certaintly don't - that's what the ";" closing character is for!!!
And jeez, all that unnecessary whitespace! Pah...
You can make pages verbose, without using stupid format conventions that take up space! After all, why format the formatting code...? (such as HTML - but applies to PHP,VBScript,Javascript, etc.)
P.S: A 1.3+ Terrabyte script?! I wonder how long that imaginary file would take to execute on the server... lol yeah, right...
Last edited by trojjer; Jul 31st, 2002 at 06:13 PM.
<% Session("OwNeD")=True %><html><body>Blah... <%="Now get your ass back to the twilight zone..."%></body></html>
-
Jul 31st, 2002, 08:29 PM
#37
Stuck in the 80s
Re: A new line for each statement?!
Originally posted by trojjer
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
Employers? I know people who have been told they didn't get the job because of things like that. The employer looks at your work and see's a confusing mess, he's going to hand you a candy cane and tell you to go home.
So if you every want a job, you should care. If you're just going to make piss-ass programs for the rest of your life, feel free.
-
Jul 31st, 2002, 09:01 PM
#38
Frenzied Member
Re: A new line for each statement?!
Originally posted by trojjer
Yo! My first post...
Er, don't mean to critiscise anyone, but who cares about not putting each statement on a new line?!
I certaintly don't - that's what the ";" closing character is for!!!
And jeez, all that unnecessary whitespace! Pah...
You can make pages verbose, without using stupid format conventions that take up space! After all, why format the formatting code...? (such as HTML - but applies to PHP,VBScript,Javascript, etc.)
dude I don't believe you just said that. I would hate to see your code.
fjdksa fl;sdlthisjg dfksajf dkisdfjska l;fjd sakl;onej gdsfkalf;jdksla ;longfj dskalfj;d skal;linefjdksafj dskla;
can you tell what that line just said? no I bet you can't, give me a break will ya. it's only human to make it so it is readable.
suppose you made that 1.3 TB file for Tom huh?
-
Jul 31st, 2002, 09:38 PM
#39
Hyperactive Member
That script would take more than 24 hours to lead from a server, It'll probablt make the server crash with that many lines and we all know you're lieing so shut the **** up and leard how to set a cookie!!! END OF DISCUSSION!, PS. You're a retard
Kevin Carpenter
Currently Working in the CAOS (CA Operating System) Group
-
Aug 2nd, 2002, 10:07 PM
#40
Thread Starter
Fanatic Member
heh, it worked
wow, 5 miles. we can walk on it.
i love to write code in one line or 2 with no spaces, ; between them, that way, no one would peek it.

prog_tom
JOIN THE REVOLUTION!!!! Dual T3 backedup science community.
http://physics.sviesoft.com/forum
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|