Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #7631

Re: setcookie() returns FALSE

From "M. Strobel" <sorry_no_mail_here@nowhere.dee>
Newsgroups comp.lang.php
Subject Re: setcookie() returns FALSE
Date 2012-11-23 10:52 +0100
Message-ID <ah8vbiFo72U1@mid.uni-berlin.de> (permalink)
References <955870ad-2574-4c6d-b57e-d0af7bafdd64@googlegroups.com>

Show all headers | View raw


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.

Back to comp.lang.php | Previous | Next — Previous in thread | Find similar | Unroll thread


Thread

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

csiph-web