diff --git a/bin/pack.php b/bin/pack.php
index f69cafbdf80cb24dd58a8d714de16d6b14c9896a..3328cf20d8346065615e78c6ad258e0929ac57cc 100755
--- a/bin/pack.php
+++ b/bin/pack.php
@@ -12,7 +12,7 @@ if (count($argv) < 1) {
 }
 
 // Needed in order to make session_start to be called before output is printed.
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $config = SimpleSAML_Configuration::getConfig('config.php');
 
 
diff --git a/docs/simplesamlphp-sp-migration.txt b/docs/simplesamlphp-sp-migration.txt
index 7b425e0e0dd48da8c041d8351a7947ad1aaa6734..0e4481b96e5ab443b5e14ab39af1c34a0717ac96 100644
--- a/docs/simplesamlphp-sp-migration.txt
+++ b/docs/simplesamlphp-sp-migration.txt
@@ -155,7 +155,7 @@ This is a quick overview of the API:
 Generally, if you have:
 
     $config = SimpleSAML_Configuration::getInstance();
-    $session = SimpleSAML_Session::getInstance();
+    $session = SimpleSAML_Session::getSessionFromRequest();
 
 you should replace it with this single line:
 
diff --git a/lib/SimpleSAML/Auth/BWC.php b/lib/SimpleSAML/Auth/BWC.php
index 3cdddf584b6ccbf11d175f4e89cd74adc04487de..f66203fce2319efd4cb3d6c5dedf5b6edea1b5d4 100644
--- a/lib/SimpleSAML/Auth/BWC.php
+++ b/lib/SimpleSAML/Auth/BWC.php
@@ -101,7 +101,7 @@ class SimpleSAML_Auth_BWC extends SimpleSAML_Auth_Simple {
 			$params['ReturnTo'] = SimpleSAML_Utilities::createPostRedirectLink($params['ReturnTo'], $_POST);
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		$authnRequest = array(
 			'IsPassive' => isset($params['isPassive']) ? $params['isPassive'] : FALSE,
@@ -152,7 +152,7 @@ class SimpleSAML_Auth_BWC extends SimpleSAML_Auth_Simple {
 			$url = SimpleSAML_Utilities::selfURL();
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		if (!$session->isValid($this->authority)) {
 			/* Not authenticated to this authentication source. */
 			SimpleSAML_Utilities::redirectTrustedURL($url);
diff --git a/lib/SimpleSAML/Auth/Default.php b/lib/SimpleSAML/Auth/Default.php
index ca02e748eca51984f49c8bb39766dca55f415a89..90d3d08c80e43a2cbfbc7f58b9b0f3c96e62db6e 100644
--- a/lib/SimpleSAML/Auth/Default.php
+++ b/lib/SimpleSAML/Auth/Default.php
@@ -124,7 +124,7 @@ class SimpleSAML_Auth_Default {
 		$return = $state['SimpleSAML_Auth_Default.Return'];
 
 		/* Save session state. */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->doLogin($state['SimpleSAML_Auth_Default.id'], self::extractPersistentAuthState($state));
 
 		if (is_string($return)) {
@@ -155,7 +155,7 @@ class SimpleSAML_Auth_Default {
 		assert('is_string($returnURL)');
 		assert('is_string($authority) || is_null($authority)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		if ($authority === NULL) {
 			$authority = $session->getAuthority();
@@ -235,7 +235,7 @@ class SimpleSAML_Auth_Default {
 
 		$source = $state['SimpleSAML_Auth_Default.logoutSource'];
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$authId = $session->getAuthority();
 
 		if ($authId !== $source) {
@@ -270,7 +270,7 @@ class SimpleSAML_Auth_Default {
 		assert('is_string($authId)');
 		assert('is_string($redirectTo)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->doLogin($authId, self::extractPersistentAuthState($state));
 
 		SimpleSAML_Utilities::redirectUntrustedURL($redirectTo);
diff --git a/lib/SimpleSAML/Auth/Simple.php b/lib/SimpleSAML/Auth/Simple.php
index 804383052bf0d9615ed5c4d7344f131b7d274c22..db14112a8f801a56389da395c295ffb65ec09ac4 100644
--- a/lib/SimpleSAML/Auth/Simple.php
+++ b/lib/SimpleSAML/Auth/Simple.php
@@ -48,7 +48,7 @@ class SimpleSAML_Auth_Simple {
 	 * @return bool  TRUE if the user is authenticated, FALSE if not.
 	 */
 	public function isAuthenticated() {
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		return $session->isValid($this->authSource);
 	}
@@ -70,7 +70,7 @@ class SimpleSAML_Auth_Simple {
 	 */
 	public function requireAuth(array $params = array()) {
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		if ($session->isValid($this->authSource)) {
 			/* Already authenticated. */
@@ -176,7 +176,7 @@ class SimpleSAML_Auth_Simple {
 			assert('isset($params["ReturnStateParam"]) && isset($params["ReturnStateStage"])');
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		if ($session->isValid($this->authSource)) {
 			$state = $session->getAuthData($this->authSource, 'LogoutState');
 			if ($state !== NULL) {
@@ -241,7 +241,7 @@ class SimpleSAML_Auth_Simple {
 		}
 
 		/* Authenticated. */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		return $session->getAuthData($this->authSource, 'Attributes');
 	}
 
@@ -259,7 +259,7 @@ class SimpleSAML_Auth_Simple {
 			return NULL;
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		return $session->getAuthData($this->authSource, $name);
 	}
 
@@ -275,7 +275,7 @@ class SimpleSAML_Auth_Simple {
 			return NULL;
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		return $session->getAuthState($this->authSource);
 	}
 
diff --git a/lib/SimpleSAML/Auth/Source.php b/lib/SimpleSAML/Auth/Source.php
index 802035e4e2903e76a1a2f854a275bd3f075611ec..29effde13a3ad18d66d8b4a97c2ac893390ac6bd 100644
--- a/lib/SimpleSAML/Auth/Source.php
+++ b/lib/SimpleSAML/Auth/Source.php
@@ -111,7 +111,7 @@ abstract class SimpleSAML_Auth_Source {
 		assert('isset($state["ReturnCallback"])');
 
 		/* The default implementation just copies over the previous authentication data. */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$data = $session->getAuthState($this->authId);
 		foreach ($data as $k => $v) {
 			$state[$k] = $v;
@@ -294,7 +294,7 @@ abstract class SimpleSAML_Auth_Source {
 			);
 
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setData('SimpleSAML_Auth_Source.LogoutCallbacks', $id, $data,
 			SimpleSAML_Session::DATA_TIMEOUT_LOGOUT);
 	}
@@ -315,7 +315,7 @@ abstract class SimpleSAML_Auth_Source {
 
 		$id = strlen($this->authId) . ':' . $this->authId . $assoc;
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		$data = $session->getData('SimpleSAML_Auth_Source.LogoutCallbacks', $id);
 		if ($data === NULL) {
diff --git a/lib/SimpleSAML/Auth/State.php b/lib/SimpleSAML/Auth/State.php
index ccea15f0ec1059cb49ced833831dbde3dedd76c5..a8600b1f39046702d802526f6b0c6fe7c486a523 100644
--- a/lib/SimpleSAML/Auth/State.php
+++ b/lib/SimpleSAML/Auth/State.php
@@ -160,7 +160,7 @@ class SimpleSAML_Auth_State {
 
 		/* Save state. */
 		$serializedState = serialize($state);
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setData('SimpleSAML_Auth_State', $id, $serializedState, self::getStateTimeout());
 
 		SimpleSAML_Logger::debug('Saved state: ' . var_export($return, TRUE));
@@ -213,7 +213,7 @@ class SimpleSAML_Auth_State {
 
 		$sid = SimpleSAML_Utilities::parseStateID($id);
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$state = $session->getData('SimpleSAML_Auth_State', $sid['id']);
 
 		if ($state === NULL) {
@@ -274,7 +274,7 @@ class SimpleSAML_Auth_State {
 
 		SimpleSAML_Logger::debug('Deleting state: ' . var_export($state[self::ID], TRUE));
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->deleteData('SimpleSAML_Auth_State', $state[self::ID]);
 	}
 
diff --git a/lib/SimpleSAML/Error/Error.php b/lib/SimpleSAML/Error/Error.php
index ff1870863c398b5b8911e206ec4d6e7b07cdeeac..67cf293bc9902863fdc7389fce801aa320d8e884 100644
--- a/lib/SimpleSAML/Error/Error.php
+++ b/lib/SimpleSAML/Error/Error.php
@@ -207,7 +207,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
 		SimpleSAML_Logger::error('Error report with id ' . $reportId . ' generated.');
 
 		$config = SimpleSAML_Configuration::getInstance();
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		if (isset($_SERVER['HTTP_REFERER'])) {
 			$referer = $_SERVER['HTTP_REFERER'];
@@ -270,7 +270,7 @@ class SimpleSAML_Error_Error extends SimpleSAML_Error_Exception {
 			$data['errorReportAddress'] = $baseurl . 'errorreport.php';
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$attributes = $session->getAttributes();
 		if (is_array($attributes) && array_key_exists('mail', $attributes) && count($attributes['mail']) > 0) {
 			$data['email'] = $attributes['mail'][0];
diff --git a/lib/SimpleSAML/IdP.php b/lib/SimpleSAML/IdP.php
index 119231a00e532eb7531c05f17f751bde7351e79f..130a6ec5f417543d6c432f7b8a20d2ae58fe25b9 100644
--- a/lib/SimpleSAML/IdP.php
+++ b/lib/SimpleSAML/IdP.php
@@ -211,7 +211,7 @@ class SimpleSAML_IdP {
 
 		$association['core:IdP'] = $this->id;
 		
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->addAssociation($this->associationGroup, $association);
 	}
 
@@ -223,7 +223,7 @@ class SimpleSAML_IdP {
 	 */
 	public function getAssociations() {
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		return $session->getAssociations($this->associationGroup);
 	}
 
@@ -236,7 +236,7 @@ class SimpleSAML_IdP {
 	public function terminateAssociation($assocId) {
 		assert('is_string($assocId)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->terminateAssociation($this->associationGroup, $assocId);
 	}
 
@@ -260,7 +260,7 @@ class SimpleSAML_IdP {
 		assert('is_callable($state["Responder"])');
 
 		if (isset($state['core:SP'])) {
-			$session = SimpleSAML_Session::getInstance();
+			$session = SimpleSAML_Session::getSessionFromRequest();
 			$session->setData('core:idp-ssotime', $state['core:IdP'] . ';' . $state['core:SP'],
 				time(), SimpleSAML_Session::DATA_TIMEOUT_LOGOUT);
 		}
@@ -292,7 +292,7 @@ class SimpleSAML_IdP {
 		}
 
 		if (isset($state['core:SP'])) {
-			$session = SimpleSAML_Session::getInstance();
+			$session = SimpleSAML_Session::getSessionFromRequest();
 			$previousSSOTime = $session->getData('core:idp-ssotime', $state['core:IdP'] . ';' . $state['core:SP']);
 			if ($previousSSOTime !== NULL) {
 				$state['PreviousSSOTimestamp'] = $previousSSOTime;
diff --git a/lib/SimpleSAML/Logger.php b/lib/SimpleSAML/Logger.php
index 71a175a51a1118b3367aee001845bd8023c7dc14..40c798097ebf2499928a716d9690d86a8f888603 100644
--- a/lib/SimpleSAML/Logger.php
+++ b/lib/SimpleSAML/Logger.php
@@ -303,7 +303,7 @@ class SimpleSAML_Logger
             self::$trackid = self::$TRACKID_FETCHING;
 
             // get the current session. This could cause recursion back to the logger class
-            $session = SimpleSAML_Session::getInstance();
+            $session = SimpleSAML_Session::getSessionFromRequest();
 
             // update the track ID
             self::$trackid = $session->getTrackID();
diff --git a/lib/SimpleSAML/Session.php b/lib/SimpleSAML/Session.php
index 468bddfe41a7975f1ca3e5c1586c69dbf5fa921a..a20b1a21a9afa25930b6902a1c86c260a8c4a12d 100644
--- a/lib/SimpleSAML/Session.php
+++ b/lib/SimpleSAML/Session.php
@@ -191,14 +191,23 @@ class SimpleSAML_Session {
     }
 
 
-	/**
+    /**
+     * @deprecated
+     * @see SimpleSAML_Session::getSessionFromRequest()
+     */
+    public static function getInstance() {
+        return self::getSessionFromRequest();
+    }
+
+
+    /**
 	 * Retrieves the current session. Will create a new session if there isn't a session.
 	 *
 	 * @return SimpleSAML_Session The current session.
 	 * @throws Exception When session couldn't be initialized and
 	 * the session fallback is disabled by configuration.
 	 */
-	public static function getInstance() {
+	public static function getSessionFromRequest() {
 
 		/* Check if we already have initialized the session. */
 		if (isset(self::$instance)) {
diff --git a/lib/SimpleSAML/Utilities.php b/lib/SimpleSAML/Utilities.php
index 18925686a0dfdd6d6efb4efa9a2c030015210906..4ab3dc1dd2aaaabab8a83aa14005bfd765c2e860 100644
--- a/lib/SimpleSAML/Utilities.php
+++ b/lib/SimpleSAML/Utilities.php
@@ -1622,7 +1622,7 @@ class SimpleSAML_Utilities {
 	 */
 	public static function isAdmin() {
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 
 		return $session->isValid('admin') || $session->isValid('login-admin');
 	}
@@ -1726,7 +1726,7 @@ class SimpleSAML_Utilities {
 				'url' => $destination,
 			);
 
-			$session = SimpleSAML_Session::getInstance();
+			$session = SimpleSAML_Session::getSessionFromRequest();
 			$session->setData('core_postdatalink', $postId, $postData);
 
 			$url = SimpleSAML_Module::getModuleURL('core/postredirect.php', array('RedirId' => $postId));
@@ -1753,7 +1753,7 @@ class SimpleSAML_Utilities {
 			'url' => $destination,
 		);
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setData('core_postdatalink', $postId, $postData);
 
 		$redirInfo = base64_encode(self::aesEncrypt($session->getSessionId() . ':' . $postId));
@@ -2105,7 +2105,7 @@ class SimpleSAML_Utilities {
 	public static function checkCookie($retryURL = NULL) {
 		assert('is_string($retryURL) || is_null($retryURL)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		if ($session->hasSessionCookie()) {
 			return;
 		}
diff --git a/lib/SimpleSAML/XHTML/IdPDisco.php b/lib/SimpleSAML/XHTML/IdPDisco.php
index 7e7eeb93859b95e88925ddbf7cf795edf11359c9..2e06cddae2a97fb3a489fe197cec060d8c8ee9b5 100644
--- a/lib/SimpleSAML/XHTML/IdPDisco.php
+++ b/lib/SimpleSAML/XHTML/IdPDisco.php
@@ -98,7 +98,7 @@ class SimpleSAML_XHTML_IdPDisco {
 		/* Initialize standard classes. */
 		$this->config = SimpleSAML_Configuration::getInstance();
 		$this->metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-		$this->session = SimpleSAML_Session::getInstance();
+		$this->session = SimpleSAML_Session::getSessionFromRequest();
 		$this->instance = $instance;
 		$this->metadataSets = $metadataSets;
 
diff --git a/modules/InfoCard/www/getcardform.php b/modules/InfoCard/www/getcardform.php
index c4dd9af684d58013597e584a48335739b587ea7d..76f4690c332ffbe74f0e58c7c755d34f5884a61e 100644
--- a/modules/InfoCard/www/getcardform.php
+++ b/modules/InfoCard/www/getcardform.php
@@ -19,7 +19,7 @@ $Infocard =   $autoconfig->getValue('InfoCard');
 
 
 /* Load the session of the current user. */
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 if (!array_key_exists('AuthState', $_REQUEST)) {
 SimpleSAML_Logger::debug('NO AUTH STATE');
diff --git a/modules/InfoCard/www/login-infocard.php b/modules/InfoCard/www/login-infocard.php
index 9d0ae3bf64a007ab0cbf2b493e355f8a49a3bde0..97a399b5e707742a4a6ef542a89eb91b343ad7a7 100644
--- a/modules/InfoCard/www/login-infocard.php
+++ b/modules/InfoCard/www/login-infocard.php
@@ -26,7 +26,7 @@ $contact_info_URL = $autoconfig->getValue('contact_info_URL');
 
 
 /* Load the session of the current user. */
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 
 if (!array_key_exists('AuthState', $_REQUEST)) {
diff --git a/modules/core/lib/Auth/Process/ExtendIdPSession.php b/modules/core/lib/Auth/Process/ExtendIdPSession.php
index 84616811d0c56c92342d939db820794c2bb72344..7a6df577753515f08e23373e48af6da510055106 100644
--- a/modules/core/lib/Auth/Process/ExtendIdPSession.php
+++ b/modules/core/lib/Auth/Process/ExtendIdPSession.php
@@ -24,7 +24,7 @@ class sspmod_core_Auth_Process_ExtendIdPSession extends SimpleSAML_Auth_Processi
 		}
 
 		/* Update authority expire time */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setAuthorityExpire($state['Authority']);
 
 		/* Update session cookies duration */
diff --git a/modules/core/www/bwc_resumeauth.php b/modules/core/www/bwc_resumeauth.php
index df937077d15ff6dd58e05c0a82893465a2e9e07f..c704ed2c23caaf15c3714f2f9801c09fbb186e64 100644
--- a/modules/core/www/bwc_resumeauth.php
+++ b/modules/core/www/bwc_resumeauth.php
@@ -5,7 +5,7 @@ if (!isset($_REQUEST['RequestID'])) {
 }
 
 /* Backwards-compatibility with old authentication pages. */
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $requestcache = $session->getAuthnRequest('saml2', (string)$_REQUEST['RequestID']);
 if (!$requestcache) {
 	throw new Exception('Could not retrieve cached RequestID = ' . $authId);
diff --git a/modules/core/www/frontpage_auth.php b/modules/core/www/frontpage_auth.php
index 6ba33d18e520fa1c7af925a008abe5ba2f4361eb..28d45304d812baa251a3101950eb348a992ccc69 100644
--- a/modules/core/www/frontpage_auth.php
+++ b/modules/core/www/frontpage_auth.php
@@ -3,7 +3,7 @@
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 /* Check if valid local session exists.. */
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_config.php b/modules/core/www/frontpage_config.php
index f4bb8f552bd2a7fb0e8471929009ced2f9c98200..c911f904b231351338013c86b3d8c606741d023a 100644
--- a/modules/core/www/frontpage_config.php
+++ b/modules/core/www/frontpage_config.php
@@ -4,7 +4,7 @@
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 /* Check if valid local session exists.. */
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_federation.php b/modules/core/www/frontpage_federation.php
index 072ad6c5ea26bb17dfc2a969f024f4c4779eef3e..d502e7bab41f9a0a7882a2e7a955737b7b55603f 100644
--- a/modules/core/www/frontpage_federation.php
+++ b/modules/core/www/frontpage_federation.php
@@ -4,7 +4,7 @@
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 /* Check if valid local session exists.. */
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/frontpage_welcome.php b/modules/core/www/frontpage_welcome.php
index fa08477371138da0ae218b55f0194b1c28019198..281237a9b121b2d135da8c7d2a162ee8e0ed33eb 100644
--- a/modules/core/www/frontpage_welcome.php
+++ b/modules/core/www/frontpage_welcome.php
@@ -3,7 +3,7 @@
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 /* Check if valid local session exists.. */
 if ($config->getBoolean('admin.protectindexpage', false)) {
diff --git a/modules/core/www/idp/resumeauth.php b/modules/core/www/idp/resumeauth.php
index b9e24fe208f425e9fe4d11e6b5e167eb2199bc74..dff0cb337816c61bac60b583991de4ca713abacc 100644
--- a/modules/core/www/idp/resumeauth.php
+++ b/modules/core/www/idp/resumeauth.php
@@ -7,7 +7,7 @@ if (!isset($_REQUEST['RequestID'])) {
 }
 
 /* Backwards-compatibility with old authentication pages. */
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $requestcache = $session->getAuthnRequest('saml2', (string)$_REQUEST['RequestID']);
 if (!$requestcache) {
 	throw new Exception('Could not retrieve cached RequestID = ' . $authId);
diff --git a/modules/core/www/postredirect.php b/modules/core/www/postredirect.php
index fd9bef458ebedf22dcd1b78badbf3884e8e837a3..d414050f2af302057acd16843d0f7d777992e32a 100644
--- a/modules/core/www/postredirect.php
+++ b/modules/core/www/postredirect.php
@@ -9,7 +9,7 @@
 
 if (array_key_exists('RedirId', $_REQUEST)) {
 	$postId = $_REQUEST['RedirId'];
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 } elseif (array_key_exists('RedirInfo', $_REQUEST)) {
 	$encData = base64_decode($_REQUEST['RedirInfo']);
 
diff --git a/modules/core/www/show_metadata.php b/modules/core/www/show_metadata.php
index e7647d2e4a8b4ecbcca6a44509e19d7ca7ae8bf5..b2e9d96fb83cbc65247c7b6f5e7c5dde9961becc 100644
--- a/modules/core/www/show_metadata.php
+++ b/modules/core/www/show_metadata.php
@@ -4,7 +4,7 @@
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Utilities::requireAdmin();
 
diff --git a/modules/cron/www/croninfo.php b/modules/cron/www/croninfo.php
index 0e55715631f38ccb94194db77cbb801d1369dd42..a0ecd68d92584aca9bceed974e86030d56b34055 100644
--- a/modules/cron/www/croninfo.php
+++ b/modules/cron/www/croninfo.php
@@ -9,7 +9,7 @@ require_once('_include.php');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Utilities::requireAdmin();
 
diff --git a/modules/logpeek/www/index.php b/modules/logpeek/www/index.php
index 2389e31ea28f8a5fa41fd623fae4e8af4157c38b..3ae3e70996a84073b4f84a2119fa8267792ed425 100644
--- a/modules/logpeek/www/index.php
+++ b/modules/logpeek/www/index.php
@@ -19,7 +19,7 @@ function logFilter($objFile, $tag, $cut){
 
 
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Utilities::requireAdmin();
 
diff --git a/modules/metaedit/www/xmlimport.php b/modules/metaedit/www/xmlimport.php
index 12f6072116b802eb5e9e1f39632db8ee3ff293ce..12799af05aa580f847d9230529d2a41ca5dd5ccf 100644
--- a/modules/metaedit/www/xmlimport.php
+++ b/modules/metaedit/www/xmlimport.php
@@ -3,7 +3,7 @@
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 $template = new SimpleSAML_XHTML_Template($config, 'metaedit:xmlimport.tpl.php');
 $template->show();
diff --git a/modules/multiauth/lib/Auth/Source/MultiAuth.php b/modules/multiauth/lib/Auth/Source/MultiAuth.php
index ea74df5a88eb91bb3104ac87d2a126e5132777ed..1bac37ad2874ae5d182fa37613c9ff2224ec7bd1 100644
--- a/modules/multiauth/lib/Auth/Source/MultiAuth.php
+++ b/modules/multiauth/lib/Auth/Source/MultiAuth.php
@@ -149,7 +149,7 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		}
 
 		/* Save the selected authentication source for the logout process. */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setData(self::SESSION_SOURCE, $state[self::AUTHID], $authId);
 
 		try {
@@ -175,7 +175,7 @@ class sspmod_multiauth_Auth_Source_MultiAuth extends SimpleSAML_Auth_Source {
 		assert('is_array($state)');
 
 		/* Get the source that was used to authenticate */
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$authId = $session->getData(self::SESSION_SOURCE, $this->authId);
 
 		$source = SimpleSAML_Auth_Source::getById($authId);
diff --git a/modules/negotiate/lib/Auth/Source/Negotiate.php b/modules/negotiate/lib/Auth/Source/Negotiate.php
index 173114cf1ff285d9b2ff2d46dffb6f15565a1e47..7689186c25db00426b82a12893ed78c38f75ecf3 100644
--- a/modules/negotiate/lib/Auth/Source/Negotiate.php
+++ b/modules/negotiate/lib/Auth/Source/Negotiate.php
@@ -80,7 +80,7 @@ class sspmod_negotiate_Auth_Source_Negotiate extends SimpleSAML_Auth_Source {
 			$this->fallBack($state);
 		// Go straight to fallback if Negotiate is disabled or if you are
 		// sent back to the IdP directly from the SP after having logged out
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$disabled = $session->getData('negotiate:disable', 'session');
 
 		if ($disabled or
@@ -309,7 +309,7 @@ click <a href="'.htmlspecialchars($url).'">here</a>.
 		SimpleSAML_Logger::debug('Negotiate - logout has the following authId: "'.$authId.'"');
 
 		if ($authId === NULL) {
-			$session = SimpleSAML_Session::getInstance();
+			$session = SimpleSAML_Session::getSessionFromRequest();
 			$session->setData('negotiate:disable', 'session', TRUE, 24*60*60);
 			parent::logout($state);
 		} else {
diff --git a/modules/negotiate/www/disable.php b/modules/negotiate/www/disable.php
index ca8bb8d00e8819891f60efe46ce36d879a7f4f63..42b09c0f03b6abf5b04d2bafb3754176fe7a606a 100644
--- a/modules/negotiate/www/disable.php
+++ b/modules/negotiate/www/disable.php
@@ -17,7 +17,7 @@ $params = array(
 SimpleSAML_Utilities::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', 'True', $params, FALSE);
 
 $globalConfig = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:disable.php');
 $t->show();
diff --git a/modules/negotiate/www/enable.php b/modules/negotiate/www/enable.php
index e28bde1f91cfdd2e540373f0420af74315eb0a04..1bf30f2cff7dd855b337d188f5a55534a783bf8f 100644
--- a/modules/negotiate/www/enable.php
+++ b/modules/negotiate/www/enable.php
@@ -16,7 +16,7 @@ $params = array(
 SimpleSAML_Utilities::setCookie('NEGOTIATE_AUTOLOGIN_DISABLE_PERMANENT', NULL, $params, FALSE);
 
 $globalConfig = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 $t = new SimpleSAML_XHTML_Template($globalConfig, 'negotiate:enable.php');
 $t->show();
diff --git a/modules/negotiate/www/retry.php b/modules/negotiate/www/retry.php
index 1f75c61d60c5d9988f083b9adff3b1d4c07e8e91..b36290e440df75e62013b308e9c7dd88b2a38c2d 100644
--- a/modules/negotiate/www/retry.php
+++ b/modules/negotiate/www/retry.php
@@ -28,7 +28,7 @@ if (isset($idpmeta['auth'])) {
 	if ($source === NULL)
 		throw new SimpleSAML_Error_BadRequest('Invalid AuthId "' . $idpmeta['auth'] . '" - not found.');
 
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 	$session->setData('negotiate:disable', 'session', FALSE, 24*60*60);
 	SimpleSAML_Logger::debug('Negotiate(retry) - session enabled, retrying.');
 	$source->authenticate($state);
diff --git a/modules/oauth/bin/demo.php b/modules/oauth/bin/demo.php
index 49ebad860a4fdf168cf65ff11e74b698b6aad5ff..b1dcf520cc5caeea24b3f94dd4e60c148ac0abcd 100755
--- a/modules/oauth/bin/demo.php
+++ b/modules/oauth/bin/demo.php
@@ -20,7 +20,7 @@ try {
 	require_once(dirname(dirname(__FILE__)) . '/libextinc/OAuth.php');
 
 	// Needed in order to make session_start to be called before output is printed.
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 
 	//$baseurl = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'https://foodle.feide.no/simplesaml');
 	$baseurl = (isset($_SERVER['argv'][1]) ? $_SERVER['argv'][1] : 'http://mars.foodle.local/simplesaml');
diff --git a/modules/oauth/www/authorize.php b/modules/oauth/www/authorize.php
index 583c86efc924ca084c73ff3e8021ca8fbe50b634..ed92f146047b190c1232d1b595e6cc73433dff0e 100644
--- a/modules/oauth/www/authorize.php
+++ b/modules/oauth/www/authorize.php
@@ -26,7 +26,7 @@ try {
 
 
 	$config = SimpleSAML_Configuration::getInstance();
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 
 	$as = $oauthconfig->getString('auth');
 	if (!$session->isValid($as)) {
diff --git a/modules/oauth/www/registry.edit.php b/modules/oauth/www/registry.edit.php
index f4a5ea30639d678dda5c654857ec4a28645a3291..972e1046158269c1707d0850d929d66d0b59514a 100644
--- a/modules/oauth/www/registry.edit.php
+++ b/modules/oauth/www/registry.edit.php
@@ -2,7 +2,7 @@
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/oauth/www/registry.php b/modules/oauth/www/registry.php
index d562bb06b7a624c7ec1c6572799ae366546c7e1a..c7ac52c7f2ef886e3e34e954a391a0d48f29b0f1 100644
--- a/modules/oauth/www/registry.php
+++ b/modules/oauth/www/registry.php
@@ -2,7 +2,7 @@
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $oauthconfig = SimpleSAML_Configuration::getOptionalConfig('module_oauth.php');
 
 $store = new sspmod_core_Storage_SQLPermanentStorage('oauth');
diff --git a/modules/openid/lib/SessionStore.php b/modules/openid/lib/SessionStore.php
index a084d0919626819c0a505a9877f722425930f48f..2dc31a57f199d95bed50a89b29eefe35701b4568 100644
--- a/modules/openid/lib/SessionStore.php
+++ b/modules/openid/lib/SessionStore.php
@@ -20,7 +20,7 @@ class sspmod_openid_SessionStore {
 	public function get($key) {
 		assert('is_string($key)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		return $session->getData('openid.session', $key);
 	}
 
@@ -34,7 +34,7 @@ class sspmod_openid_SessionStore {
 	public function set($key, $value) {
 		assert('is_string($key)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->setData('openid.session', $key, $value);
 	}
 
@@ -47,7 +47,7 @@ class sspmod_openid_SessionStore {
 	public function del($key) {
 		assert('is_string($key)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->deleteData('openid.session', $key);
 	}
 
diff --git a/modules/saml/lib/Auth/Source/SP.php b/modules/saml/lib/Auth/Source/SP.php
index a23cb0fe9bccbdef159973fa4e4f60083d2f9753..565ad663156eea11243914dacd15eec346f865dd 100644
--- a/modules/saml/lib/Auth/Source/SP.php
+++ b/modules/saml/lib/Auth/Source/SP.php
@@ -403,7 +403,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 	public function reauthenticate(array &$state) {
 		assert('is_array($state)');
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$data = $session->getAuthState($this->authId);
 		foreach ($data as $k => $v) {
 			$state[$k] = $v;
@@ -438,7 +438,7 @@ class sspmod_saml_Auth_Source_SP extends SimpleSAML_Auth_Source {
 		assert('isset($state["ReturnCallback"])');
 
 		// Update session state
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$session->doLogin($state['saml:sp:AuthId'], SimpleSAML_Auth_Default::extractPersistentAuthState($state));
 
 		// resume the login process
diff --git a/modules/saml/lib/IdP/SAML2.php b/modules/saml/lib/IdP/SAML2.php
index f7b45d1d1db9f25821afc6841ef9f0fe77640bc2..0557290995d54787360d2dae7e9666c5d988dff1 100644
--- a/modules/saml/lib/IdP/SAML2.php
+++ b/modules/saml/lib/IdP/SAML2.php
@@ -798,7 +798,7 @@ class sspmod_saml_IdP_SAML2 {
 			$a->setAuthnInstant($state['AuthnInstant']);
 		} else {
 			/* For backwards compatibility. Remove in version 1.8. */
-			$session = SimpleSAML_Session::getInstance();
+			$session = SimpleSAML_Session::getSessionFromRequest();
 			$a->setAuthnInstant($session->getAuthnInstant());
 		}
 
diff --git a/modules/saml/lib/SP/LogoutStore.php b/modules/saml/lib/SP/LogoutStore.php
index 93bef896e77b76abc4ca06b343429e608e4b56e7..6ad352f53ed7a65c3cf846984b5864729de27ee9 100644
--- a/modules/saml/lib/SP/LogoutStore.php
+++ b/modules/saml/lib/SP/LogoutStore.php
@@ -187,7 +187,7 @@ class sspmod_saml_SP_LogoutStore {
 			$sessionIndex = sha1($sessionIndex);
 		}
 
-		$session = SimpleSAML_Session::getInstance();
+		$session = SimpleSAML_Session::getSessionFromRequest();
 		$sessionId = $session->getSessionId();
 
 		if ($store instanceof SimpleSAML_Store_SQL) {
diff --git a/modules/saml/www/sp/saml2-acs.php b/modules/saml/www/sp/saml2-acs.php
index dc0375834aa2a1efe4485d767e21949fbc80083b..1341095cbd89b36ef6f4d71b237fa9e689a8ee65 100644
--- a/modules/saml/www/sp/saml2-acs.php
+++ b/modules/saml/www/sp/saml2-acs.php
@@ -34,7 +34,7 @@ if ($idp === NULL) {
 	}
 }
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $prevAuth = $session->getAuthData($sourceId, 'saml:sp:prevAuth');
 if ($prevAuth !== NULL && $prevAuth['id'] === $response->getId() && $prevAuth['issuer'] === $idp) {
 	/* OK, it looks like this message has the same issuer
diff --git a/modules/statistics/www/showstats.php b/modules/statistics/www/showstats.php
index babdcf2cda19036bdb2f3cf04d1e10c39b2782bd..0af0e9d6742baed964f2c78ad34c23436f3f46f4 100644
--- a/modules/statistics/www/showstats.php
+++ b/modules/statistics/www/showstats.php
@@ -2,7 +2,7 @@
 
 $config = SimpleSAML_Configuration::getInstance();
 $statconfig = SimpleSAML_Configuration::getConfig('module_statistics.php');
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 
 sspmod_statistics_AccessCheck::checkAccess($statconfig);
diff --git a/www/auth/login-admin.php b/www/auth/login-admin.php
index 306dda0a25516f0c9f35257347c5304f00343c8e..5a53b83732f17926bc241c4e4681d5b4c27c7af0 100644
--- a/www/auth/login-admin.php
+++ b/www/auth/login-admin.php
@@ -12,7 +12,7 @@ require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-admin.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login-cas-ldap.php b/www/auth/login-cas-ldap.php
index 7a7325d1954c06e07a580955d62a09b91dee445b..3a6b835f80183c24b274df4258a5567f3ac4f528 100644
--- a/www/auth/login-cas-ldap.php
+++ b/www/auth/login-cas-ldap.php
@@ -22,7 +22,7 @@
 require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-cas-ldap.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login-ldapmulti.php b/www/auth/login-ldapmulti.php
index 4db2fdb7469596d9fe8a716b9bc56afbce2a3b4b..9364aef42a5593250fc748e0f61ab61104f10375 100644
--- a/www/auth/login-ldapmulti.php
+++ b/www/auth/login-ldapmulti.php
@@ -12,7 +12,7 @@ require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-ldapmulti.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login-radius.php b/www/auth/login-radius.php
index d8d785b7fd43902724105b3bd42cc16cf7ba8110..cec122aaf5eb3fa657da6c8d42db4b26c2ae55c7 100644
--- a/www/auth/login-radius.php
+++ b/www/auth/login-radius.php
@@ -12,7 +12,7 @@ require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-radius.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login-tlsclient.php b/www/auth/login-tlsclient.php
index 71930ef3f153f3ee68e2e939134e2c155f0d9a58..414f4d52fe6d8c4eb7806964e462fac766aed2a4 100644
--- a/www/auth/login-tlsclient.php
+++ b/www/auth/login-tlsclient.php
@@ -12,7 +12,7 @@ require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-tlsclient.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login-wayf-ldap.php b/www/auth/login-wayf-ldap.php
index c0ad0a9b7e1e3c3bfb897ff620c1b92fa256609d..a1539c5273f590aa776d2198e96f16e49ee25ca0 100644
--- a/www/auth/login-wayf-ldap.php
+++ b/www/auth/login-wayf-ldap.php
@@ -22,7 +22,7 @@
 require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login-wayf-ldap.php is deprecated and will be removed in future versions.');
 
diff --git a/www/auth/login.php b/www/auth/login.php
index d334fbfa674f075786a7f882482e8ba54f8f4c2f..d0b0fdda3761c03049b16a1e2ecc5c1380eeefe1 100644
--- a/www/auth/login.php
+++ b/www/auth/login.php
@@ -12,7 +12,7 @@ require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file auth/login.php is deprecated and will be removed in future versions.');
 
diff --git a/www/authmemcookie.php b/www/authmemcookie.php
index a4e877a7c4dbb04be1ae001dd5587c8dfb759c97..b385400c9031b63fa36625960da7b64cb6e5bf3d 100644
--- a/www/authmemcookie.php
+++ b/www/authmemcookie.php
@@ -105,7 +105,7 @@ try {
 	$memcache->set($sessionID, $data, 0, $expirationTime);
 
 	/* Register logout handler. */
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 	$session->registerLogoutHandler('SimpleSAML_AuthMemCookie', 'logoutHandler');
 
 	/* Redirect the user back to this page to signal that the login is completed. */
diff --git a/www/errorreport.php b/www/errorreport.php
index 0abb624c6626329b96b2a6b23009d15e7ec92ce0..3ce5246dc3356e7edfa9ca5922b5bc859cb9a1c8 100644
--- a/www/errorreport.php
+++ b/www/errorreport.php
@@ -18,7 +18,7 @@ $email = (string)$_REQUEST['email'];
 $text = htmlspecialchars((string)$_REQUEST['text']);
 
 try {
-	$session = SimpleSAML_Session::getInstance();
+	$session = SimpleSAML_Session::getSessionFromRequest();
 	$data = $session->getData('core:errorreport', $reportId);
 } catch (Exception $e) {
 	SimpleSAML_Logger::error('Error loading error report data: ' . var_export($e->getMessage(), TRUE));
diff --git a/www/example-simple/attributequery.php b/www/example-simple/attributequery.php
index 890a1e49f32c867ac42076a14c74e8be7f580f88..76932baf6f6c91e849a294c76fcc58d277db40b6 100644
--- a/www/example-simple/attributequery.php
+++ b/www/example-simple/attributequery.php
@@ -10,7 +10,7 @@
 
 require_once('../_include.php');
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 SimpleSAML_Logger::warning('The file example-simple/attributequery.php is deprecated and will be removed in future versions.');
diff --git a/www/example-simple/hostnames.php b/www/example-simple/hostnames.php
index 87e5ca4220111d03b57e1c1bc983142d32ad6d70..e92e26dd640bdfaed3428e2ff13f3291e8b00405 100644
--- a/www/example-simple/hostnames.php
+++ b/www/example-simple/hostnames.php
@@ -4,7 +4,7 @@ require_once('../_include.php');
 
 /* Load simpleSAMLphp, configuration */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 /* Check if valid local session exists.. */
 SimpleSAML_Utilities::requireAdmin();
diff --git a/www/example-simple/saml2-example.php b/www/example-simple/saml2-example.php
index 7c48d5faea831045944b7f8332bb3eee45964899..5fdc83b60df93c0ca951bd9253819c6fed42598c 100644
--- a/www/example-simple/saml2-example.php
+++ b/www/example-simple/saml2-example.php
@@ -27,7 +27,7 @@ session_cache_limiter('nocache');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file example-simple/saml2-example.php is deprecated and will be removed in future versions.');
 
diff --git a/www/example-simple/shib13-example.php b/www/example-simple/shib13-example.php
index 96d78b3ded296a69dc2bfbb89059290a2d72257c..4b275ed8369af34edd8aed9e00f840bb35d1fd46 100644
--- a/www/example-simple/shib13-example.php
+++ b/www/example-simple/shib13-example.php
@@ -27,7 +27,7 @@ session_cache_limiter('nocache');
 
 /* Load simpleSAMLphp, configuration and metadata */
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file example-simple/shib13-example.php is deprecated and will be removed in future versions.');
 
diff --git a/www/example-simple/wsfed-example.php b/www/example-simple/wsfed-example.php
index 5335d0d3de1462697dcd199968edcfadd66f16a1..166fc61b3f4f0150b433585b7f3402f5b8dfd8c9 100644
--- a/www/example-simple/wsfed-example.php
+++ b/www/example-simple/wsfed-example.php
@@ -11,7 +11,7 @@
 require_once('../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file example-simple/wsfed-example.php is deprecated and will be removed in future versions.');
 
diff --git a/www/saml2/sp/AssertionConsumerService.php b/www/saml2/sp/AssertionConsumerService.php
index 88dbc5c3c7417a29fb725760979db04fd94b445d..5c0a8e1730cd65e807bcdff7576e813f1cef6016 100644
--- a/www/saml2/sp/AssertionConsumerService.php
+++ b/www/saml2/sp/AssertionConsumerService.php
@@ -27,7 +27,7 @@ SimpleSAML_Logger::warning('The file saml2/sp/AssertionConsumerService.php is de
 /* Get the session object for the user. Create a new session if no session
  * exists for this user.
  */
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 
 /**
diff --git a/www/saml2/sp/SingleLogoutService.php b/www/saml2/sp/SingleLogoutService.php
index e0b6f8a3251366fadaac3553b615a58332e1ede1..e21b65ccb82444e33346eec567dbcd13b67d78b3 100644
--- a/www/saml2/sp/SingleLogoutService.php
+++ b/www/saml2/sp/SingleLogoutService.php
@@ -16,7 +16,7 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 SimpleSAML_Logger::warning('The file saml2/sp/SingleLogoutService.php is deprecated and will be removed in future versions.');
 
 // Get the local session
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 
 SimpleSAML_Logger::info('SAML2.0 - SP.SingleLogoutService: Accessing SAML 2.0 SP endpoint SingleLogoutService');
diff --git a/www/saml2/sp/initSLO.php b/www/saml2/sp/initSLO.php
index de4f3810fbace32dddcb2a12dc05e824840d6b4a..50b2d035fe00b29b2efc22b94dc32b948e7889bb 100644
--- a/www/saml2/sp/initSLO.php
+++ b/www/saml2/sp/initSLO.php
@@ -12,7 +12,7 @@ require_once('../../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file saml2/sp/initSLO.php is deprecated and will be removed in future versions.');
 
diff --git a/www/saml2/sp/initSSO.php b/www/saml2/sp/initSSO.php
index 55ca0efc0988c2666945d61b7fabcd3d7927916d..ef1acc2396d2c4f3976335570664c0f16c53c834 100644
--- a/www/saml2/sp/initSSO.php
+++ b/www/saml2/sp/initSSO.php
@@ -12,7 +12,7 @@ require_once('../../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::warning('The file saml2/sp/initSSO.php is deprecated and will be removed in future versions.');
 
diff --git a/www/shib13/sp/AssertionConsumerService.php b/www/shib13/sp/AssertionConsumerService.php
index 9e59d0ac791e96d223ea7c2803315392f5760f79..ab1fd6874390fca97191e4665ed573db0fe785f0 100644
--- a/www/shib13/sp/AssertionConsumerService.php
+++ b/www/shib13/sp/AssertionConsumerService.php
@@ -14,7 +14,7 @@ $config = SimpleSAML_Configuration::getInstance();
 
 SimpleSAML_Logger::warning('The file shib13/sp/AssertionConsumerService.php is deprecated and will be removed in future versions.');
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 
 /**
diff --git a/www/shib13/sp/initSSO.php b/www/shib13/sp/initSSO.php
index de5f74eca039893b720ad35d5dd3f84b91b44220..2cceb210e0aa6508fca6c0d22133a683902053ee 100644
--- a/www/shib13/sp/initSSO.php
+++ b/www/shib13/sp/initSSO.php
@@ -15,7 +15,7 @@ $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 SimpleSAML_Logger::warning('The file shib13/sp/initSSO.php is deprecated and will be removed in future versions.');
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 		
 
 /*
diff --git a/www/wsfed/sp/initSLO.php b/www/wsfed/sp/initSLO.php
index 001d8fb74699cff632283b279e9db025c1510343..a30e294c97f800a6d2a07dda276e530ccf992499 100644
--- a/www/wsfed/sp/initSLO.php
+++ b/www/wsfed/sp/initSLO.php
@@ -14,7 +14,7 @@ $config = SimpleSAML_Configuration::getInstance();
 
 SimpleSAML_Logger::warning('The file wsfed/sp/initSLO.php is deprecated and will be removed in future versions.');
 
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 
 SimpleSAML_Logger::info('WS-Fed - SP.initSLO: Accessing WS-Fed SP initSLO script');
 
diff --git a/www/wsfed/sp/prp.php b/www/wsfed/sp/prp.php
index 606222b265ef6b25459cbf83a714147ebd8b302e..219930d071d303476579c57e41cf28479622796c 100644
--- a/www/wsfed/sp/prp.php
+++ b/www/wsfed/sp/prp.php
@@ -24,7 +24,7 @@
 require_once('../../_include.php');
 
 $config = SimpleSAML_Configuration::getInstance();
-$session = SimpleSAML_Session::getInstance();
+$session = SimpleSAML_Session::getSessionFromRequest();
 $metadata = SimpleSAML_Metadata_MetaDataStorageHandler::getMetadataHandler();
 
 SimpleSAML_Logger::warning('The file wsfed/sp/prp.php is deprecated and will be removed in future versions.');