From fdee56c21d2eaa9fa6574fab531deb3ef13ea5dc Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Wed, 28 Nov 2007 14:31:43 +0000
Subject: [PATCH] SessionHandlerPHP: Don't call session_start() if it has been
 called earlier.

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

diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index cd669ee99..c669aeee9 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -21,8 +21,15 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
 		 */
 		parent::__construct();
 
-		/* Initialize the php session handling. */
-		session_start();
+		/* Initialize the php session handling.
+		 *
+		 * If session_id() returns a blank string, then we need
+		 * to call session start. Otherwise the session is already
+		 * started, and we should avoid calling session_start().
+		 */
+		if(session_id === '') {
+			session_start();
+		}
 	}
 
 
-- 
GitLab