diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index b35bd96ede77ba2087705039732d427a335bb2c6..808cb8b7a03e0801a5f5f4e6dca9fbc544370306 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -760,12 +760,16 @@ class SimpleSAML_Session {
 	 * the data should be written back with setData.
 	 *
 	 * @param $type  The type of the data. This must match the type used when adding the data.
-	 * @param $id    The identifier of the data.
+	 * @param $id    The identifier of the data. Can be NULL, in which case NULL will be returned.
 	 * @return The data of the given type with the given id or NULL if the data doesn't exist in the data store.
 	 */
 	public function getData($type, $id) {
-		assert(is_string($type));
-		assert(is_string($id));
+		assert('is_string($type)');
+		assert('$id === NULL || is_string($id)');
+
+		if($id === NULL) {
+			return NULL;
+		}
 
 		$this->expireData();