From 03d72a8f4943b936a6653d8658b657aed0e8f17f Mon Sep 17 00:00:00 2001
From: Olav Morken <olav.morken@uninett.no>
Date: Wed, 14 May 2008 07:55:13 +0000
Subject: [PATCH] Allow session_save_path to be overridden by setting the
 session.phpsession.savepath option in config.php.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@556 44740490-163a-0410-bde0-09ae8108e29a
---
 config-templates/config.php          | 4 ++++
 lib/SimpleSAML/SessionHandlerPHP.php | 5 +++++
 2 files changed, 9 insertions(+)

diff --git a/config-templates/config.php b/config-templates/config.php
index 2b80c424d..4c2cc0af5 100644
--- a/config-templates/config.php
+++ b/config-templates/config.php
@@ -123,8 +123,12 @@ $config = array (
 	'session.duration'		=>  8 * (60*60), // 8 hours.
 	'session.requestcache'	=>  4 * (60*60), // 4 hours
 	
+	/*
+	 * Options to override the default settings for php sessions.
+	 */
 	'session.phpsession.cookiename'  => null,
 	'session.phpsession.limitedpath' => false,
+	'session.phpsession.savepath'    => null,
 	
 	/*
 	 * Languages available and what language is default
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index d3a96f5c8..70a20f47e 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -41,6 +41,11 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
 			$cookiename = $config->getValue('session.phpsession.cookiename', NULL);
 			if (!empty($cookiename)) session_name($cookiename);
 
+			$savepath = $config->getValue('session.phpsession.savepath', NULL);
+			if(!empty($savepath)) {
+				session_save_path($savepath);
+			}
+
 			if(!array_key_exists(session_name(), $_COOKIE)) {
 				/* Session cookie unset - session id not set. Generate new (secure) session id. */
 				session_id(SimpleSAML_Utilities::stringToHex(SimpleSAML_Utilities::generateRandomBytes(16)));
-- 
GitLab