--- session-no-anon.inc	2009-05-29 23:24:27.000000000 -0400
+++ session-no-anon.inc_patched	2010-09-23 14:40:51.000000000 -0400
@@ -24,8 +24,6 @@ function sess_read($key) {
 
   // Handle the case of first time visitors and clients that don't store cookies (eg. web crawlers).
   if (!isset($_COOKIE[session_name()])) {
-    // Modification for no_anon module: turn off session cookies
-    ini_set('session.use_cookies', 0);
     $user = drupal_anonymous_user();
     return '';
   }
@@ -61,15 +59,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.
-  //
-  // Modification for no_anon module: eliminate anonymous sessions.
-  // Note that the throttle module, and the "Who's Online" block does not work.
-  if (!session_save_session() || $user->uid == 0) {
+  // statistics. 
+  if (!session_save_session() || ($user->uid == 0 && empty($value) && empty($user->session))) {
     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.
