Skip navigation


6 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)
7 drupal_set_message($message = NULL, $type = 'status', $repeat = TRUE)

Set a message which reflects the status of the performed operation.

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


$message: The message to be displayed to the user. For consistency with other messages, it should begin with a capital letter and end with a period.

$type: The type of the message. One of the following values are possible:

  • 'status'
  • 'warning'
  • 'error'

$repeat: If this is FALSE and the message is already set, then the message won't be repeated.

379 calls to drupal_set_message()


drupal/includes/, line 1513
Functions that need to be loaded on every Drupal request.


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

    if ($repeat || !in_array($message, $_SESSION['messages'][$type])) {
      $_SESSION['messages'][$type][] = $message;

    // Mark this page as being uncacheable.

  // Messages not set when DB connection fails.
  return isset($_SESSION['messages']) ? $_SESSION['messages'] : NULL;