ILIAS  eassessment Revision 61809
 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 _getUsersWithIp ($a_ip)
 Get the active users with a specific remote ip address.

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

Member Function Documentation

static ilSession::_destroy (   $a_session_id)
static

Destroy session.

Parameters
stringsession id

Definition at line 170 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 186 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 200 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 217 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 151 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 19 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 249 of file class.ilSession.php.

References $ilDB, $query, and $row.

Referenced by ilWebAccessChecker\determineUser().

{
global $ilDB;
$users = array();
if (!$ilDB->tableColumnExists('usr_session', 'remote_addr'))
{
return $users;
}
$query = "SELECT DISTINCT user_id FROM usr_session"
. " WHERE remote_addr = " . $ilDB->quote($a_ip, "text")
. " AND user_id > 0";
$result = $ilDB->query($query);
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 37 of file class.ilSession.php.

References $_SESSION, $GLOBALS, $ilDB, $ilSetting, _destroyExpiredSessions(), _exists(), and ilSessionControl\DEFAULT_MAX_IDLE.

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;
}
if( $ilSetting->get('session_handling_type', 0) == 0)
{
// fixed session
$expires = time() + ini_get("session.gc_maxlifetime");
}
else if( $ilSetting->get('session_handling_type', 0) == 1)
{
// load dependent session settings
$expires = time() + (int)($ilSetting->get('session_max_idle', ilSessionControl::DEFAULT_MAX_IDLE) * 60);
}
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:


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