Drupal: drupal_set_message does not display a message

I cannot receive a message from drupal_set_message when a user logs in to my site. I am using Drupal 6.14.

Adding print to user.module:

function user_register_submit($form, &$form_state) { ... if ($notify) { ... } else { drupal_set_message(t('Your password and further instructions have been sent to your e-mail address.')); print 'xxxxxx'; $form_state['redirect'] = ''; return; } } ... } 

He prints 'xxxxx';

A var_dump $_SESSION variable gives a status message that drupal_set_message does not display, so it also looks good.

I uninstalled all my modules, remained only the main one, and now I use Garland as a theme.

In addition, I installed a new Drupal installation, and there it gives me a good status message.

Then I compared my .htaccess and Drupal from a new installation. Modified mine to make them equal.

Nothing helps.

Any thoughts?

+6
drupal
source share
6 answers

beautifully made to find the reason - I had the same problem a couple of weeks ago.

Now for this reason:

Drupal sessions are linked by an identification number (you can see this in the session table in the database, if you look) to the user. Drupal also has its own session processing functions, and one of them is checking to see if the current session is associated with a valid user account, and for anonymous users, i.e. user 0 - (it doesn’t matter if several sessions are open for each user - which, of course, happens when so many anonymous users visit your site).

If Drupal does not find a valid user for the current session, the session is regenerated again - this means that previous information is lost.

Edit:

A recent comment prompted me to add a little more depth to the answer, since I have since found the most likely cause of the error.

Basically, this is using identifier 0 for an anonymous user. If you insert the value 0 in the auto-incrementing field in MySQL, the value will actually become the next available value in the sequence (so a table with an automatically increasing field set to 10 will be INSERT at 11, not 0).

We ran into a problem because we used MySQL dumps to export and import backups during development.

+10
source share

We just decided. Apparently, user 0 was absent, someone deleted it, or some module did it. Having inserted it into the database, we again received our messages.

This is what you need to do:

 INSERT INTO `users` (`uid`, `name`, `pass`, `mail`, `mode`, `sort`, `threshold`, `theme`, `signature`, `signature_format`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`) VALUES (0, '', '', '', 0, 0, 0, '', '', 0, 0, 0, 0, 0, NULL, '', '', '', NULL); 

And after that set uid to 0, because uid is an auto increment !!

I don’t know yet how this error is with drupal_set_message.

+11
source share

Another problem might be that your theme does not print $ message in templates.

+4
source share

I could not receive messages even if you make theme_get_messages () or echo $ messages etc.

So I had to get it from $ _SESSION ['messages'].

t

 <?php // we aren't getting messages, get them manually if (isset($_SESSION['messages'])) { echo '<div class="messages">'; foreach($_SESSION['messages'] as $type=>$messages) { echo "<p class=\"$type\">".implode("</p><p class=\"$type\">", $messages)."</p>"; } echo '</div>'; unset($_SESSION['messages']); } ?> 

Hope this helps someone.

+2
source share

I find this for a long time, this is the reason for other modules that you install that affect this you can apply this code in phpmyadmin o on the console if you use linux.

 INSERT INTO `users` (`uid`, `name`, `pass`, `mail`, `theme`, `signature`, `signature_format`, `created`, `access`, `login`, `status`, `timezone`, `language`, `picture`, `init`, `data`) VALUES (0, '', '', '', '', '', 0, 0, 0, 0, 0, NULL, '', '', '', NULL); 
+1
source share

drupal_set_message($msg, $type = 'status'); allows you to set a message, it will be displayed automatically on the next (or current) page that the user is visiting.

See docs: http://api.drupal.org/api/function/drupal_set_message/6

0
source share

All Articles