diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 35d9e27efcb5eb0d0edee9a83edb8d3310b95e40..68bceaddc11dc234d4254ab8861016b505e0286a 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -81,7 +81,17 @@ class SimpleSAML_Session {
 		
 		$this->trackid = SimpleSAML_Utilities::generateTrackID();
 	}
-	
+
+
+	/**
+	 * This function is called after this class has been deserialized.
+	 */
+	public function __wakeup() {
+		/* Initialize the $logger class variable if it hasn't been initialized. */
+		if (self::$logger === NULL) {
+			self::$logger = new SimpleSAML_Logger();
+		}
+	}
 	
 	
 	public static function getInstance($allowcreate = false) {