diff --git a/includes/session.inc b/includes/session.inc
index eaf6fc5..8ed2266 100644
--- a/includes/session.inc
+++ b/includes/session.inc
@@ -60,12 +60,18 @@ function sess_write($key, $value) {
   // If saving of session data is disabled or if the client doesn't have a session,
   // and one isn't being created ($value), do nothing. This keeps crawlers out of
   // the session table. This reduces memory and server load, and gives more useful
-  // statistics. We can't eliminate anonymous session table rows without breaking
-  // the throttle module and the "Who's Online" block.
+  // statistics.
   if (!session_save_session() || ($user->uid == 0 && empty($_COOKIE[session_name()]) && empty($value))) {
     return TRUE;
   }
 
+// Special case to remove notification messages but preserve $_SESSION from other modules if any
+  if ($user->uid == 0 && !empty($user->session) && preg_match('|messages|is', $user->session)) {
+    session_decode($value);
+    unset($_SESSION['messages']);
+    $value = session_encode();
+  }
+
   db_query("UPDATE {sessions} SET uid = %d, cache = %d, hostname = '%s', session = '%s', timestamp = %d WHERE sid = '%s'", $user->uid, isset($user->cache) ? $user->cache : '', ip_address(), $value, time(), $key);
   if (db_affected_rows()) {
     // Last access time is updated no more frequently than once every 180 seconds.
