Add SimpleSAML_Session::DATA_TIMEOUT_SESSION_END (issue #570).
git-svn-id: http://simplesamlphp.googlecode.com/svn/trunk@3272 44740490-163a-0410-bde0-09ae8108e29a
This commit is contained in:
parent
339b15b7ae
commit
85896393b4
|
@ -189,7 +189,7 @@ Example code for the function with GeoIP country check:
|
|||
}
|
||||
|
||||
if ($init) {
|
||||
$session->setData($data_type, $data_key, $remote_addr);
|
||||
$session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -209,7 +209,7 @@ Example code for the function with GeoIP country check:
|
|||
|
||||
if ($country_a === $country_b) {
|
||||
if ($stored_remote_addr !== $remote_addr) {
|
||||
$session->setData($data_type, $data_key, $remote_addr);
|
||||
$session->setData($data_type, $data_key, $remote_addr, SimpleSAML_Session::DATA_TIMEOUT_SESSION_END);
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
|
|
|
@ -21,6 +21,13 @@ class SimpleSAML_Session {
|
|||
const DATA_TIMEOUT_LOGOUT = 'logoutTimeout';
|
||||
|
||||
|
||||
/**
|
||||
* This is a timeout value for setData, which indicates that the data
|
||||
* should never be deleted, i.e. lasts the whole session lifetime.
|
||||
*/
|
||||
const DATA_TIMEOUT_SESSION_END = 'sessionEndTimeout';
|
||||
|
||||
|
||||
/**
|
||||
* The list of loaded session objects.
|
||||
*
|
||||
|
@ -804,6 +811,11 @@ class SimpleSAML_Session {
|
|||
continue;
|
||||
}
|
||||
|
||||
if ($info['expires'] === self::DATA_TIMEOUT_SESSION_END) {
|
||||
/* This data never expires. */
|
||||
continue;
|
||||
}
|
||||
|
||||
if($ct > $info['expires']) {
|
||||
unset($typedData[$id]);
|
||||
}
|
||||
|
@ -874,7 +886,7 @@ class SimpleSAML_Session {
|
|||
public function setData($type, $id, $data, $timeout = NULL) {
|
||||
assert('is_string($type)');
|
||||
assert('is_string($id)');
|
||||
assert('is_int($timeout) || is_null($timeout) || $timeout === self::DATA_TIMEOUT_LOGOUT');
|
||||
assert('is_int($timeout) || is_null($timeout) || $timeout === self::DATA_TIMEOUT_LOGOUT || $timeout === self::DATA_TIMEOUT_SESSION_END');
|
||||
|
||||
/* Clean out old data. */
|
||||
$this->expireData();
|
||||
|
@ -902,6 +914,8 @@ class SimpleSAML_Session {
|
|||
|
||||
if ($timeout === self::DATA_TIMEOUT_LOGOUT) {
|
||||
$expires = self::DATA_TIMEOUT_LOGOUT;
|
||||
} elseif ($timeout === self::DATA_TIMEOUT_SESSION_END) {
|
||||
$expires = self::DATA_TIMEOUT_SESSION_END;
|
||||
} else {
|
||||
$expires = time() + $timeout;
|
||||
}
|
||||
|
|
Reference in New Issue