drupal_set_message

Definition

drupal_set_message($message = NULL, $type = 'status')
includes/bootstrap.inc, line 597

Description

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.

Code

<?php
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'];
}
?>
 
 

All source code and documentation on this site is released under the terms of the GNU General Public License, version 2 and later. Drupal is a registered trademark of Dries Buytaert.