From 55f8e2b6bd3105481230f124d6fa41cac7066751 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Mon, 9 Aug 2010 08:51:46 +0000 Subject: [PATCH] Session: Track session ID in session object. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2495 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Session.php | 28 ++++++++++++++++++++++++++++ 1 file changed, 28 insertions(+) diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 9e6de47bf..5c52cbd9c 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -26,6 +26,15 @@ class SimpleSAML_Session { */ private static $instance = null; + + /** + * The session ID of this session. + * + * @var string|NULL + */ + private $sessionId; + + /** * The track id is a new random unique identifier that is generate for each session. * This is used in the debug logs and error messages to easily track more information @@ -127,6 +136,9 @@ class SimpleSAML_Session { return; } + $sh = SimpleSAML_SessionHandler::getSessionHandler(); + $this->sessionId = $sh->getCookieSessionId(); + $this->trackid = substr(md5(uniqid(rand(), true)), 0, 10); $this->dirty = TRUE; @@ -200,6 +212,17 @@ class SimpleSAML_Session { } + /** + * Retrieve the session ID of this session. + * + * @return string|NULL The session ID, or NULL if this is a transient session. + */ + public function getSessionId() { + + return $this->sessionId; + } + + /** * Get a unique ID that will be permanent for this session. * Used for debugging and tracing log files related to a session. @@ -754,6 +777,11 @@ class SimpleSAML_Session { assert('$session instanceof self'); + /* For backwardscompatibility. Remove after 1.7. */ + if ($session->sessionId === NULL) { + $session->sessionId = $sh->getCookieSessionId(); + } + if ($session->authToken !== NULL) { if (!isset($_COOKIE['SimpleSAMLAuthToken'])) { SimpleSAML_Logger::warning('Missing AuthToken cookie.'); -- GitLab