Index: includes/objects/Database.php
===================================================================
--- includes/objects/Database.php	(revision 12650)
+++ includes/objects/Database.php	(working copy)
@@ -77,6 +77,17 @@
     }
 
 /**
+ * Destructor to save the session  before the database connection dies
+/**/
+    function __destruct() {
+        // Restore global db object reference for session write
+        global $db;
+        $db = $this;
+        // Ask session to write and close now, before we lose the db object forever
+        session_write_close();
+    }
+
+/**
  * This takes the place of a database constructor.  It should be called directly
  * without an object as:
  *
