Re: setcookie() not working - help!

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
  Thank you for the reply.
  The problem was in the line 55, as I told. This line was the one in which the setcookie() was writen.
  But now I solved the problem by just moving the whole script at the beginning of the file, that is before the html and doctype tags. As is writen in the documentation. (This documentation is great, by the way).
  Cannot modify header information, as I understood in this way, means that cookies actions, like setcookie(), are actions which take place before any html document is created by php, which  means that a setcookie method cannot take place after the html code is created, that is when it is writen after any html tag.
  This make sense actually. Cookies are pieces of information that php needs in order to create a "personalized" html document. Therefore, it makes no sense in writing them after html tags.
  Thanks once more for your support.
  Liviu
   
  
Niel Archer <niel@xxxxxxxxxxxxx> wrote:
  Hi

In the example code you sent, I can't see any reason for an error. Is
this a verbatim copy of your code?

As Stut implied, the reported error and the documentation tells you
everything you should need to know in this case, and as with any problem
the documentation should be your first resource. However the error is a
little vague as to whether the setcookie() is the cause of the error or
if header output is attempted afterwards. If this is not your complete
code, and the setcookie is the cause, then you have output before it
somewhere, else there is header output after it.

I think you might want to change your condition too.

> $cookie = $_COOKIE['cookie'];

this will set $cookie regardless (with the appropriate value or an
empty string), so that:

> if(!isset($cookie)){

always fails

it would be better to do

if(!isset($_COOKIE['cookie'])){

or

if(!empty($cookie)){



Niel

-- 
PHP Windows Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



 __________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 

[Index of Archives]     [PHP Home]     [PHP Users]     [PHP Database Programming]     [PHP Install]     [Kernel Newbies]     [Yosemite Forum]     [PHP Books]

  Powered by Linux