diff --git a/lib/SimpleSAML/SessionHandlerStore.php b/lib/SimpleSAML/SessionHandlerStore.php
index d17b25be58d369af134984aa8aca0616cfef4b8b..725e719437a577b1ad80f73783f262df407e22a4 100644
--- a/lib/SimpleSAML/SessionHandlerStore.php
+++ b/lib/SimpleSAML/SessionHandlerStore.php
@@ -67,11 +67,13 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie {
 	 */
 	public function saveSession(SimpleSAML_Session $session) {
 
+		$sessionId = $session->getSessionId();
+
 		$config = SimpleSAML_Configuration::getInstance();
 		$sessionDuration = $config->getInteger('session.duration', 8*60*60);
 		$expire = time() + $sessionDuration;
 
-		$this->store->set('session', $this->session_id, $session, $expire);
+		$this->store->set('session', $sessionId, $session, $expire);
 	}
 
 }