Skip to content
Snippets Groups Projects
Commit 9834b4b9 authored by Olav Morken's avatar Olav Morken
Browse files

SessionHandler: Support loading a specific session.

git-svn-id: https://simplesamlphp.googlecode.com/svn/trunk@2497 44740490-163a-0410-bde0-09ae8108e29a
parent b1584502
No related branches found
No related tags found
No related merge requests found
......@@ -66,9 +66,10 @@ abstract class SimpleSAML_SessionHandler {
/**
* Load the session.
*
* @param string|NULL $sessionId The ID of the session we should load, or NULL to use the default.
* @return SimpleSAML_Session|NULL The session object, or NULL if it doesn't exist.
*/
abstract public function loadSession();
abstract public function loadSession($sessionId = NULL);
/**
......
......@@ -89,9 +89,15 @@ class SimpleSAML_SessionHandlerPHP extends SimpleSAML_SessionHandler {
/**
* Load the session from the PHP session array.
*
* @param string|NULL $sessionId The ID of the session we should load, or NULL to use the default.
* @return SimpleSAML_Session|NULL The session object, or NULL if it doesn't exist.
*/
public function loadSession() {
public function loadSession($sessionId = NULL) {
assert('is_string($sessionId) || is_null($sessionId)');
if ($sessionId !== NULL && $sessionId !== session_id()) {
throw new SimpleSAML_Error_Exception('Cannot load PHP session with a specific ID.');
}
if (!isset($_SESSION['SimpleSAMLphp_SESSION'])) {
return NULL;
......
......@@ -26,11 +26,17 @@ class SimpleSAML_SessionHandlerStore extends SimpleSAML_SessionHandlerCookie {
/**
* Load the session from the datastore.
*
* @param string|NULL $sessionId The ID of the session we should load, or NULL to use the default.
* @return SimpleSAML_Session|NULL The session object, or NULL if it doesn't exist.
*/
public function loadSession() {
public function loadSession($sessionId = NULL) {
assert('is_string($sessionId) || is_null($sessionId)');
$session = $this->store->get('session', $this->session_id);
if ($sessionId === NULL) {
$sessionId = $this->session_id;
}
$session = $this->store->get('session', $sessionId);
if ($session !== NULL) {
assert('$session instanceof SimpleSAML_Session');
return $session;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment