From 96721a24631229c048ed94b911c12e8cedc765b9 Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Wed, 28 Nov 2007 14:52:40 +0000
Subject: [PATCH] SessionHandlerPHP: Check if a key exists in the session
 before trying to access it (in order to avoid notice-messages in the log).

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@88 44740490-163a-0410-bde0-09ae8108e29a
---
 lib/SimpleSAML/SessionHandlerPHP.php | 10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 2a5e0e576..222312b8e 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];
 	}
 }
-- 
GitLab