diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 2a5e0e5762210522fe32ddac6684656d585b1371..222312b8e14ff36f13b5fed030ef4855a69b4950 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -49,6 +49,16 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
 	 * more information.
 	 */
 	public function get($key) {
+		/* Check if key exists first to avoid notice-messages in the
+		 * log.
+		 */
+		if(!array_key_exists($key, $_SESSION)) {
+			/* We should return NULL if we don't have that
+			 * key in the session.
+			 */
+			return NULL;
+		}
+
 		return $_SESSION[$key];
 	}
 }