How to display a message even when user is logged out? I'm using Drupal 7, i want to display a message drupal_set_message, when i click on a button for example.

When i'm logged it works well, but for this same button (or page) if i'm not logged in, it doesn't display any message.

This is my case : i've created a mobile application that used a backoffice. this backoffice is built using drupal. i've created a page "reset password" user can click on "reset password" from the mobile app, an email sent with a link to my custom page : reset_pwd

this page contains inputs to reset new password :

$items['reset_psw'] = array(
'title' =&gt; '',
    'description' =&gt; '',
    'access arguments' =&gt; array('administer reset_psw'),
    'file' =&gt; 'system.admin.inc',
    'file path' =&gt; drupal_get_path('module', 'system'),
    'page callback' =&gt; 'drupal_get_form',
    'page arguments' =&gt; array('reset_mdp_formulaire'),
);
return $items;


the form to reset password : 

function reset_mdp_formulaire ($form, &amp;$form_state){

$form = array();

$form['confirm_pass'] = array(
    '#type' =&gt; 'password_confirm',       
);

$form['valider'] = array(
    '#value' =&gt; t('valider'),
    '#type' =&gt; 'submit',           
);
return $form;
 }


the function submit :

function reset_mdp_formulaire_submit ($form, &amp;$form_state){
$new_pass = $form_state['values']['confirm_pass'];
dsm("error");
if(strlen($new_pass) &lt; 8){

    drupal_set_message(t('Password must be 8 characters at least.'), 'error'); &lt;== not shown when logged out
    return;
}
 }


Just want to check if new password is less than 8 characters, and display error message

Thank you all.
Try removing the return statement at the end of your submit or even replacing it with a drupal_goto('reset_psw').

There are lots of similar questions on google and S.O., you could have a look.

UPDATE

You should use the validate handler for such a case, this simple example should get you going https://www.drupal.org/node/717740