ILIAS  Release_4_2_x_branch Revision 61807
 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)
 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.

Data Fields

const SESSION_HANDLING_FIXED = 0
const SESSION_HANDLING_LOAD_DEPENDENT = 1

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 13 of file class.ilSession.php.

Member Function Documentation

static ilSession::_destroy (   $a_session_id)
static

Destroy session.

Parameters
stringsession id

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

References $ilDB.

Referenced by db_session_destroy(), ilSessionControl\kickOneMinIdleSession(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB;
$q = "DELETE FROM usr_session WHERE session_id = ".
$ilDB->quote($a_session_id, "text");
$ilDB->manipulate($q);
return true;
}

+ Here is the caller graph for this function:

static ilSession::_destroyByUserId (   $a_user_id)
static

Destroy session.

Parameters
stringsession id

Definition at line 197 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 211 of file class.ilSession.php.

References $ilDB.

Referenced by _writeData(), db_session_gc(), and ilSessionTest\testBasicSessionBehaviour().

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

+ 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 228 of file class.ilSession.php.

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

Referenced by duplicate_session(), 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 162 of file class.ilSession.php.

References $ilDB.

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

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

+ 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 39 of file class.ilSession.php.

References $ilDB.

Referenced by db_session_read(), and ilSessionTest\testBasicSessionBehaviour().

{
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 326 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 57 of file class.ilSession.php.

References $_SESSION, $GLOBALS, $ilDB, $ilSetting, _destroyExpiredSessions(), _exists(), and getExpireValue().

Referenced by _duplicate(), db_session_write(), and ilSessionTest\testBasicSessionBehaviour().

{
global $ilDB, $ilSetting, $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;
}
$expires = self::getExpireValue();
if (ilSession::_exists($a_session_id))
{
/*$q = "UPDATE usr_session SET ".
"expires = ".$ilDB->quote($expires, "integer").", ".
"data = ".$ilDB->quote($a_data, "clob").
", ctime = ".$ilDB->quote(time(), "integer").
", user_id = ".$ilDB->quote((int) $_SESSION["AccountId"], "integer").
" WHERE session_id = ".$ilDB->quote($a_session_id, "text");
array("integer", "clob", "integer", "integer", "text");
$ilDB->manipulate($q);*/
if ($ilClientIniFile->readVariable("session","save_ip"))
{
$ilDB->update("usr_session", array(
"user_id" => array("integer", (int) $_SESSION["AccountId"]),
"expires" => array("integer", $expires),
"data" => array("clob", $a_data),
"ctime" => array("integer", time()),
"type" => array("integer", (int) $_SESSION["SessionType"]),
"remote_addr" => array("text", $_SERVER["REMOTE_ADDR"])
), array(
"session_id" => array("text", $a_session_id)
));
}
else
{
$ilDB->update("usr_session", array(
"user_id" => array("integer", (int) $_SESSION["AccountId"]),
"expires" => array("integer", $expires),
"data" => array("clob", $a_data),
"ctime" => array("integer", time()),
"type" => array("integer", (int) $_SESSION["SessionType"])
), array(
"session_id" => array("text", $a_session_id)
));
}
}
else
{
/*$q = "INSERT INTO usr_session (session_id, expires, data, ctime,user_id) ".
"VALUES(".$ilDB->quote($a_session_id, "text").",".
$ilDB->quote($expires, "integer").",".
$ilDB->quote($a_data, "clob").",".
$ilDB->quote(time(), "integer").",".
$ilDB->quote((int) $_SESSION["AccountId"], "integer").")";
$ilDB->manipulate($q);*/
if ($ilClientIniFile->readVariable("session","save_ip"))
{
$ilDB->insert("usr_session", array(
"session_id" => array("text", $a_session_id),
"expires" => array("integer", $expires),
"data" => array("clob", $a_data),
"ctime" => array("integer", time()),
"user_id" => array("integer", (int) $_SESSION["AccountId"]),
"type" => array("integer", (int) $_SESSION["SessionType"]),
"createtime" => array("integer", time()),
"remote_addr" => array("text", $_SERVER["REMOTE_ADDR"])
));
}
else
{
$ilDB->insert("usr_session", array(
"session_id" => array("text", $a_session_id),
"expires" => array("integer", $expires),
"data" => array("clob", $a_data),
"ctime" => array("integer", time()),
"user_id" => array("integer", (int) $_SESSION["AccountId"]),
"type" => array("integer", (int) $_SESSION["SessionType"]),
"createtime" => array("integer", time())
));
}
}
// finally delete deprecated sessions
if(rand(0, 50) == 2)
{
}
return true;
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

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 264 of file class.ilSession.php.

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

Referenced by _writeData().

{
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);
}
}

+ Here is the caller graph for this function:

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 290 of file class.ilSession.php.

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

Referenced by ilAuthUtils\_initAuth(), ilTestOutputGUI\finishTest(), 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 315 of file class.ilSession.php.

References getIdleValue().

Referenced by ilObjSystemFolderGUI\displayBasicSettings(), ilObjSystemFolderGUI\initBasicSettingsForm(), and ilPersonalSettingsGUI\initGeneralSettingsForm().

{
return self::getIdleValue(true);
}

+ Here is the call graph for this function:

+ Here is the caller graph for this function:

Field Documentation


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