Undefined variable: _SESSION in template.php I use this code (not mine, I do not know how to code) to disable Maintenance mode message on front-page while developing a site, it's really annoying when it's flashing all the time in the middle of the page.

function theme_preprocess_page(&amp;$vars) {
    if (variable_get('maintenance_mode', 0)) { //no maintenance mode message on front-end
      $message_count = count($_SESSION['messages']['status']);
      if($message_count &gt; 1) {
        array_shift($_SESSION['messages']['status']);
      }
      else {
        unset($_SESSION['messages']['status']);
      }
}


So it works great while logged in and in maintenance mode, but when going to user/login page as anonymous, it gives this notice in red:

Notice: Undefined variable: _SESSION in theme_preprocess_page()
(line 141 of /sites/all/themes/mytheme/template.php).


So what is this? Is the code missing something?
Apparently the $_SESSION variable is not available on the login page (I don't know why, but probably to avoid conflicts with logged in users trying to log in again). 

Try checking for it before you try to unset it:

function theme_preprocess_page(&amp;$vars) {
    if (variable_get('maintenance_mode', 0) &amp;&amp; isset($_SESSION['messages']['status'])) { //no maintenance mode message on front-end
      $message_count = count($_SESSION['messages']['status']);
      if($message_count &gt; 1) {
        array_shift($_SESSION['messages']['status']);
      }
      else {
        unset($_SESSION['messages']['status']);
      }
    }
}