From 3c5960fd49232a5952d2c145b995c672cfaaaa32 Mon Sep 17 00:00:00 2001 From: Olav Morken <olav.morken@uninett.no> Date: Wed, 24 Feb 2010 09:52:44 +0000 Subject: [PATCH] Session: Add support for transient sessions. git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2189 44740490-163a-0410-bde0-09ae8108e29a --- lib/SimpleSAML/Session.php | 26 +++++++++++++++++++++++++- 1 file changed, 25 insertions(+), 1 deletion(-) diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php index 2947d32ec..a33740ca4 100644 --- a/lib/SimpleSAML/Session.php +++ b/lib/SimpleSAML/Session.php @@ -99,11 +99,18 @@ class SimpleSAML_Session { /** * private constructor restricts instantiaton to getInstance() */ - private function __construct() { + private function __construct($transient = FALSE) { + $configuration = SimpleSAML_Configuration::getInstance(); $this->sessionduration = $configuration->getInteger('session.duration', 8*60*60); + + if ($transient) { + $this->trackid = 'XXXXXXXXXX'; + return; + } + $this->trackid = SimpleSAML_Utilities::generateTrackID(); $this->dirty = TRUE; @@ -152,6 +159,23 @@ class SimpleSAML_Session { } + /** + * Use a transient session. + * + * Create a session that should not be saved at the end of the request. + * Subsequent calls to getInstance() will return this transient session. + */ + public static function useTransientSession() { + + if (isset(self::$instance)) { + /* We already have a session. Don't bother with a transient session. */ + return; + } + + self::$instance = new SimpleSAML_Session(TRUE); + } + + /** * Initializes a session with the specified authentication state. * -- GitLab