Re: setcookie() not working - help!

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

 



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


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

  Powered by Linux