diff --git a/lib/SimpleSAML/SessionHandler.php b/lib/SimpleSAML/SessionHandler.php
index 2a96749eafdca07f7131422edef452e454345600..1ceb3696bf800eb8309b8c2a829f06a742e1c182 100644
--- a/lib/SimpleSAML/SessionHandler.php
+++ b/lib/SimpleSAML/SessionHandler.php
@@ -48,6 +48,14 @@ abstract class SimpleSAML_SessionHandler {
 	}
 
 
+	/* This function retrieves the session id of the current session.
+	 *
+	 * Returns:
+	 *  The session id of the current session.
+	 */
+	abstract public function getSessionId();
+
+
 	/* This function is used to store data in this session object.
 	 *
 	 * Note: You are allowed to store a reference to an object in the
diff --git a/lib/SimpleSAML/SessionHandlerCookie.php b/lib/SimpleSAML/SessionHandlerCookie.php
index 6ddad436eac15db9b731904738b26dd31c55f8f7..63b7a3f3a04af1aaac5ed7c498acb386cce149ca 100644
--- a/lib/SimpleSAML/SessionHandlerCookie.php
+++ b/lib/SimpleSAML/SessionHandlerCookie.php
@@ -48,6 +48,16 @@ extends SimpleSAML_SessionHandler {
 	}
 
 
+	/* This function retrieves the session id of the current session.
+	 *
+	 * Returns:
+	 *  The session id of the current session.
+	 */
+	public function getSessionId() {
+		return $this->session_id;
+	}
+
+
 	/* This static function creates a session id. A session id consists
 	 * of 32 random hexadecimal characters.
 	 *
diff --git a/lib/SimpleSAML/SessionHandlerPHP.php b/lib/SimpleSAML/SessionHandlerPHP.php
index 222312b8e14ff36f13b5fed030ef4855a69b4950..132918662f210baa031b8c5301ea09d3a2c20b1f 100644
--- a/lib/SimpleSAML/SessionHandlerPHP.php
+++ b/lib/SimpleSAML/SessionHandlerPHP.php
@@ -33,6 +33,16 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
 	}
 
 
+	/* This function retrieves the session id of the current session.
+	 *
+	 * Returns:
+	 *  The session id of the current session.
+	 */
+	public function getSessionId() {
+		return session_id();
+	}
+
+
 	/* This function is used to store data in this session object.
 	 *
 	 * See the information in SimpleSAML_SessionHandler::set(...) for