Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #7629 > unrolled thread
| Started by | cerr <ron.eggler@gmail.com> |
|---|---|
| First post | 2012-11-22 22:26 -0800 |
| Last post | 2012-11-23 10:52 +0100 |
| Articles | 3 — 3 participants |
Back to article view | Back to comp.lang.php
setcookie() returns FALSE cerr <ron.eggler@gmail.com> - 2012-11-22 22:26 -0800
Re: setcookie() returns FALSE "Olaf S." <thesys@gmx.de> - 2012-11-23 09:53 +0100
Re: setcookie() returns FALSE "M. Strobel" <sorry_no_mail_here@nowhere.dee> - 2012-11-23 10:52 +0100
| From | cerr <ron.eggler@gmail.com> |
|---|---|
| Date | 2012-11-22 22:26 -0800 |
| Subject | setcookie() returns FALSE |
| Message-ID | <955870ad-2574-4c6d-b57e-d0af7bafdd64@googlegroups.com> |
Hi,
I have the following code:
if(setcookie("FSBO", "TEST", time()+3600)) {
echo "TRUE<br>";
} else {
echo "FALSE<br>";
}
print_r($_COOKIE);
and the ouput on my box is false. How do I know why I can't set a cookie?
Thank you!
[toc] | [next] | [standalone]
| From | "Olaf S." <thesys@gmx.de> |
|---|---|
| Date | 2012-11-23 09:53 +0100 |
| Message-ID | <50af398d$0$9505$9b4e6d93@newsspool1.arcor-online.net> |
| In reply to | #7629 |
Am 23.11.2012 07:26, schrieb cerr:
> Hi,
>
> I have the following code:
> if(setcookie("FSBO", "TEST", time()+3600)) {
> echo "TRUE<br>";
> } else {
> echo "FALSE<br>";
> }
> print_r($_COOKIE);
> and the ouput on my box is false. How do I know why I can't set a cookie?
> Thank you!
>
You many *NOT* output *ANY* Code, before you use setcookie.
NOT any whitespace, not <head> or <html>...or..or
[toc] | [prev] | [next] | [standalone]
| From | "M. Strobel" <sorry_no_mail_here@nowhere.dee> |
|---|---|
| Date | 2012-11-23 10:52 +0100 |
| Message-ID | <ah8vbiFo72U1@mid.uni-berlin.de> |
| In reply to | #7629 |
Am 23.11.2012 07:26, schrieb cerr:
> Hi,
>
> I have the following code:
> if(setcookie("FSBO", "TEST", time()+3600)) {
> echo "TRUE<br>";
> } else {
> echo "FALSE<br>";
> }
> print_r($_COOKIE);
> and the ouput on my box is false. How do I know why I can't set a cookie?
The problem is that cookies are set in the HTTP header, which are sent as soon as
there is output. If you had turned all messages on you would see an error message
telling you '...headers sent...'
see http://www.php.net/manual/en/function.headers-sent.php and the links there.
/Str.
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.php
csiph-web