echo() doesn't output anything for anonymous users I am working on my own form module for Drupal 7.

I tried to set some default text depending on a cookie was set or not. It works perfectly as long as your are logged in; once you are an anonymous user, it doesn't read/write the cookie.

I tried to debug this by putting in a few calls to echo(), and drupal_set_message(), but they are only shown when I'm logged in; they don't show for anonymous users. I can't figure out why.

Can anyone help me with this?

This is the code I am using.

$serviceType = "";
$serviceName = "";
if (isset($_COOKIE["kms_hoststring_name"])) {
  $serviceName = $_COOKIE["kms_hoststring_name"];
  $serviceType = $_COOKIE["kms_hoststring_type"];
}
drupal_set_message("test");
echo "TEST";
$form['serviceType'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Service Type:'),
  '#default_value' =&gt; t($serviceType),
);

$form['serviceName'] = array(
  '#type' =&gt; 'textfield',
  '#title' =&gt; t('Service Name'),
  '#default_value' =&gt; t($serviceName),
);

//Deletes cookies after use.
echo "TEST1";
if (isset($_COOKIE["kms_hoststring_name"])){
  setcookie("kms_hoststring_name", "", time()-60000, "/");
  setcookie("kms_hoststring_type", "", time()-60000, "/");
  echo "TEST2".$_COOKIE["kms_hoststring_name"];
}


None of the echo() or drupal_set_message() calls output anything for anonymous users.
When I log in, I see the output of those function calls.
Drupal have much better tools for debugging than echo. You can sent a message to the watchdog log with the watchdog function. And if you install the devel module you get a few more funcions like dpm() to easily send messages or dd() to write onto the drupal debug log.