ILIAS  Release_5_0_x_branch Revision 61816
 All Data Structures Namespaces Files Functions Variables Groups Pages
ilSession Class Reference
+ Collaboration diagram for ilSession:

Static Public Member Functions

static _getData ($a_session_id)
 Get session data from table.
static _writeData ($a_session_id, $a_data)
 Write session data.
static _exists ($a_session_id)
 Check whether session exists.
static _destroy ($a_session_id, $a_closing_context=null, $a_expired_at=null)
 Destroy session.
static _destroyByUserId ($a_user_id)
 Destroy session.
static _destroyExpiredSessions ()
 Destroy expired sessions.
static _duplicate ($a_session_id)
 Duplicate session.
static getExpireValue ($fixedMode=false)
 Returns the expiration timestamp in seconds.
static getIdleValue ($fixedMode=false)
 Returns the idle time in seconds.
static getSessionExpireValue ()
 Returns the session expiration value.
static _getUsersWithIp ($a_ip)
 Get the active users with a specific remote ip address.
static set ($a_var, $a_val)
 Set a value.
static get ($a_var)
 Get a value.
static clear ($a_var)
 Unset a value.
static setClosingContext ($a_context)
 set closing context (for statistics)
static getClosingContext ()
 get closing context (for statistics)

Data Fields

const SESSION_HANDLING_FIXED = 0
const SESSION_HANDLING_LOAD_DEPENDENT = 1
const SESSION_CLOSE_USER = 1
const SESSION_CLOSE_EXPIRE = 2
const SESSION_CLOSE_FIRST = 3
const SESSION_CLOSE_IDLE = 4
const SESSION_CLOSE_LIMIT = 5
const SESSION_CLOSE_LOGIN = 6
const SESSION_CLOSE_PUBLIC = 7
const SESSION_CLOSE_TIME = 8
const SESSION_CLOSE_IP = 9
const SESSION_CLOSE_SIMUL = 10
const SESSION_CLOSE_INACTIVE = 11
const SESSION_CLOSE_CAPTCHA = 12

Static Private Attributes

static $closing_context = null

Detailed Description

Author
Alex Killing alex..nosp@m.kill.nosp@m.ing@g.nosp@m.mx.d.nosp@m.e
Version
$Id:$

ilObjUser on usr_session

Definition at line 15 of file class.ilSession.php.

Member Function Documentation

static ilSession::_destroy (   $a_session_id,
  $a_closing_context = null,
  $a_expired_at = null 
)
static

Destroy session.

Parameters
string|arraysession id|s
intclosing context
int|boolexpired at timestamp

Definition at line 169 of file class.ilSession.php.

References $closing_context, $ilDB, ilSessionStatistics\closeRawEntry(), and ilSessionIStorage\destroySession().

Referenced by _destroyExpiredSessions(), ilSessionDBHandler\destroy(), ilInitialisation\initUser(), ilSessionControl\kickFirstRequestAbidencer(), ilSessionControl\kickOneMinIdleSession(), ilStartUpGUI\migrateAccount(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB;
if(!$a_closing_context)
{
$a_closing_context = self::$closing_context;
}
ilSessionStatistics::closeRawEntry($a_session_id, $a_closing_context, $a_expired_at);
if(!is_array($a_session_id))
{
$q = "DELETE FROM usr_session WHERE session_id = ".
$ilDB->quote($a_session_id, "text");
}
else
{
// array: id => timestamp - so we get rid of timestamps
if($a_expired_at)
{
$a_session_id = array_keys($a_session_id);
}
$q = "DELETE FROM usr_session WHERE ".
$ilDB->in("session_id", $a_session_id, "", "text");
}
$ilDB->manipulate($q);
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSession::_destroyByUserId (   $a_user_id)
static

Destroy session.

Parameters
stringsession id

Definition at line 209 of file class.ilSession.php.

References $ilDB.

Referenced by ilObjUser\delete(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB;
$q = "DELETE FROM usr_session WHERE user_id = ".
$ilDB->quote($a_user_id, "integer");
$ilDB->manipulate($q);
return true;
}

+ Here is the caller graph for this function:

static ilSession::_destroyExpiredSessions ( )
static

Destroy expired sessions.

Definition at line 223 of file class.ilSession.php.

References $ilDB, $res, $row, and _destroy().

Referenced by _writeData(), ilSessionStatisticsGUI\adminSync(), ilSessionDBHandler\gc(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB;
$q = "SELECT session_id,expires FROM usr_session WHERE expires < ".
$ilDB->quote(time(), "integer");
$res = $ilDB->query($q);
$ids = array();
while($row = $ilDB->fetchAssoc($res))
{
$ids[$row["session_id"]] = $row["expires"];
}
if(sizeof($ids))
{
self::_destroy($ids, self::SESSION_CLOSE_EXPIRE, true);
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSession::_duplicate (   $a_session_id)
static

Duplicate session.

Parameters
stringsession id
Returns
string new session id

Definition at line 249 of file class.ilSession.php.

References $ilDB, $query, $res, $row, and _writeData().

Referenced by ilContainer\cloneAllObject(), ilECSTaskScheduler\initNextExecution(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB;
// Create new session id
$new_session = $a_session_id;
do
{
$new_session = md5($new_session);
$q ="SELECT * FROM usr_session WHERE ".
"session_id = ".$ilDB->quote($new_session, "text");
$res = $ilDB->query($q);
} while($ilDB->fetchAssoc($res));
$query = "SELECT * FROM usr_session ".
"WHERE session_id = ".$ilDB->quote($a_session_id, "text");
$res = $ilDB->query($query);
while ($row = $ilDB->fetchObject($res))
{
ilSession::_writeData($new_session,$row->data);
return $new_session;
}
return false;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSession::_exists (   $a_session_id)
static

Check whether session exists.

Parameters
stringsession id
Returns
boolean true, if session id exists

Definition at line 149 of file class.ilSession.php.

References $ilDB.

Referenced by _writeData(), ilInitialisation\setSessionHandler(), and ilSessionTest\testBasicSessionBehaviour().

{
if (! $a_session_id) {
return false;
}
global $ilDB;
$q = "SELECT 1 FROM usr_session WHERE session_id = " . $ilDB->quote($a_session_id, "text");
$set = $ilDB->query($q);
return $ilDB->numRows($set) > 0;
}

+ Here is the caller graph for this function:

static ilSession::_getData (   $a_session_id)
static

Get session data from table.

Parameters
stringsession id
Returns
string session data

Definition at line 61 of file class.ilSession.php.

References $ilDB.

Referenced by ilSessionDBHandler\read(), and ilSessionTest\testBasicSessionBehaviour().

{
if(!$a_session_id) {
return NULL;
}
global $ilDB;
$q = "SELECT data FROM usr_session WHERE session_id = ".
$ilDB->quote($a_session_id, "text");
$set = $ilDB->query($q);
$rec = $ilDB->fetchAssoc($set);
return $rec["data"];
}

+ Here is the caller graph for this function:

static ilSession::_getUsersWithIp (   $a_ip)
static

Get the active users with a specific remote ip address.

Parameters
stringip address
Returns
array list of active user id

Definition at line 347 of file class.ilSession.php.

References $ilDB, $query, $result, and $row.

Referenced by ilWebAccessChecker\determineUser().

{
global $ilDB;
$query = "SELECT DISTINCT user_id FROM usr_session"
. " WHERE remote_addr = " . $ilDB->quote($a_ip, "text")
. " AND user_id > 0";
$result = $ilDB->query($query);
$users = array();
while ($row = $ilDB->fetchObject($result))
{
$users[] = $row->user_id;
}
return $users;
}

+ Here is the caller graph for this function:

static ilSession::_writeData (   $a_session_id,
  $a_data 
)
static

Write session data.

Parameters
stringsession id
stringsession data

Definition at line 82 of file class.ilSession.php.

References $_SESSION, $GLOBALS, $ilDB, ilSessionControl\$session_types_controlled, _destroyExpiredSessions(), _exists(), ilSessionStatistics\aggretateRaw(), and ilSessionStatistics\createRawEntry().

Referenced by _duplicate(), ilSessionTest\testBasicSessionBehaviour(), and ilSessionDBHandler\write().

{
global $ilDB, $ilClientIniFile;
if ($GLOBALS['WEB_ACCESS_WITHOUT_SESSION'])
{
// Prevent session data written for web access checker
// when no cookie was sent (e.g. for pdf files linking others).
// This would result in new session records for each request.
return false;
}
$now = time();
// prepare session data
$fields = array(
"user_id" => array("integer", (int) $_SESSION["AccountId"]),
"expires" => array("integer", self::getExpireValue()),
"data" => array("clob", $a_data),
"ctime" => array("integer", $now),
"type" => array("integer", (int) $_SESSION["SessionType"])
);
if ($ilClientIniFile->readVariable("session","save_ip"))
{
$fields["remote_addr"] = array("text", $_SERVER["REMOTE_ADDR"]);
}
if (ilSession::_exists($a_session_id))
{
$ilDB->update("usr_session", $fields,
array("session_id" => array("text", $a_session_id)));
}
else
{
$fields["session_id"] = array("text", $a_session_id);
$fields["createtime"] = array("integer", $now);
$ilDB->insert("usr_session", $fields);
// check type against session control
$type = $fields["type"][1];
{
ilSessionStatistics::createRawEntry($fields["session_id"][1],
$type, $fields["createtime"][1], $fields["user_id"][1]);
}
}
// finally delete deprecated sessions
if(rand(0, 50) == 2)
{
// get time _before_ destroying expired sessions
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSession::getClosingContext ( )
static

get closing context (for statistics)

Returns
int

Definition at line 412 of file class.ilSession.php.

References $closing_context.

static ilSession::getExpireValue (   $fixedMode = false)
static

Returns the expiration timestamp in seconds.

Parameters
booleanIf passed, the value for fixed session is returned
Returns
integer The expiration timestamp in seconds public

Definition at line 285 of file class.ilSession.php.

References $ilSetting, ilSessionControl\DEFAULT_MAX_IDLE, SESSION_HANDLING_FIXED, and SESSION_HANDLING_LOAD_DEPENDENT.

{
global $ilSetting;
if( $fixedMode || $ilSetting->get('session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_FIXED )
{
// fixed session
return time() + ini_get('session.gc_maxlifetime');
}
else if( $ilSetting->get('session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_LOAD_DEPENDENT )
{
// load dependent session settings
return time() + (int) ($ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE) * 60);
}
}
static ilSession::getIdleValue (   $fixedMode = false)
static

Returns the idle time in seconds.

Parameters
booleanIf passed, the value for fixed session is returned
Returns
integer The idle time in seconds public

Definition at line 311 of file class.ilSession.php.

References $ilSetting, ilSessionControl\DEFAULT_MAX_IDLE, SESSION_HANDLING_FIXED, and SESSION_HANDLING_LOAD_DEPENDENT.

Referenced by ilAuthUtils\_initAuth(), ilTestPlayerAbstractGUI\finishTestCmd(), ilSCORM13Player\getPlayer(), and getSessionExpireValue().

{
global $ilSetting, $ilClientIniFile;
if( $fixedMode || $ilSetting->get('session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_FIXED )
{
// fixed session
return $ilClientIniFile->readVariable('session','expire');
}
else if( $ilSetting->get('session_handling_type', self::SESSION_HANDLING_FIXED) == self::SESSION_HANDLING_LOAD_DEPENDENT )
{
// load dependent session settings
return (int) ($ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE) * 60);
}
}

+ Here is the caller graph for this function:

static ilSession::getSessionExpireValue ( )
static

Returns the session expiration value.

Returns
integer The expiration value in seconds public

Definition at line 336 of file class.ilSession.php.

References getIdleValue().

Referenced by ilObjUserFolderGUI\initFormGeneralSettings(), and ilPersonalSettingsGUI\initGeneralSettingsForm().

{
return self::getIdleValue(true);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

static ilSession::setClosingContext (   $a_context)
static

set closing context (for statistics)

Parameters
int$a_context

Definition at line 402 of file class.ilSession.php.

Referenced by ilSessionControl\checkCurrentSessionIsAllowed(), ilPersonalSettingsGUI\deleteOwnAccountLogout(), ilInitialisation\goToLogin(), ilInitialisation\goToPublicSection(), ilStartUpGUI\showLogin(), and ilStartUpGUI\showLogout().

{
self::$closing_context = (int)$a_context;
}

+ Here is the caller graph for this function:

Field Documentation

ilSession::$closing_context = null
staticprivate

Definition at line 53 of file class.ilSession.php.

Referenced by _destroy(), and getClosingContext().

const ilSession::SESSION_CLOSE_CAPTCHA = 12

Definition at line 51 of file class.ilSession.php.

Referenced by ilStartUpGUI\showLogin().

const ilSession::SESSION_CLOSE_EXPIRE = 2
const ilSession::SESSION_CLOSE_FIRST = 3
const ilSession::SESSION_CLOSE_IDLE = 4
const ilSession::SESSION_CLOSE_INACTIVE = 11

Definition at line 50 of file class.ilSession.php.

Referenced by ilStartUpGUI\showLogin().

const ilSession::SESSION_CLOSE_IP = 9

Definition at line 48 of file class.ilSession.php.

Referenced by ilStartUpGUI\showLogin().

const ilSession::SESSION_CLOSE_LIMIT = 5
const ilSession::SESSION_CLOSE_LOGIN = 6
const ilSession::SESSION_CLOSE_PUBLIC = 7

Definition at line 46 of file class.ilSession.php.

Referenced by ilInitialisation\goToPublicSection().

const ilSession::SESSION_CLOSE_SIMUL = 10

Definition at line 49 of file class.ilSession.php.

Referenced by ilStartUpGUI\showLogin().

const ilSession::SESSION_CLOSE_TIME = 8

Definition at line 47 of file class.ilSession.php.

Referenced by ilStartUpGUI\showLogin().

const ilSession::SESSION_CLOSE_USER = 1

The documentation for this class was generated from the following file: