Same name and namespace in other branches
  1. 4.7.x includes/bootstrap.inc \drupal_set_message()
  2. 5.x includes/bootstrap.inc \drupal_set_message()
  3. 6.x includes/bootstrap.inc \drupal_set_message()
  4. 7.x includes/bootstrap.inc \drupal_set_message()
  5. 8.9.x core/includes/bootstrap.inc \drupal_set_message()

Set a message for the user to see.

The message is stored in the session so that it can persist through a redirect.

If called with no arguments, this function returns all set messages without clearing them.

59 calls to drupal_set_message()
aggregator_edit in modules/aggregator.module
aggregator_parse_feed in modules/aggregator.module
aggregator_remove in modules/aggregator.module
block_admin in modules/block.module
Menu callback; displays the block overview page.
block_box_delete in modules/block.module
Menu callback; confirm and delete custom blocks.

... See full list

File

includes/bootstrap.inc, line 597
Functions that need to be loaded on every Drupal request.

Code

function drupal_set_message($message = NULL, $type = 'status') {
  if (isset($message)) {
    if (!isset($_SESSION['messages'])) {
      $_SESSION['messages'] = array();
    }
    if (!isset($_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type] = array();
    }
    $_SESSION['messages'][$type][] = $message;
  }
  return $_SESSION['messages'];
}