ILIAS  trunk Revision v11.0_alpha-2638-g80c1d007f79
ilSessionControl Class Reference
+ Collaboration diagram for ilSessionControl:

Static Public Member Functions

static handleLoginEvent (string $a_login, ilAuthSession $auth_session)
 
static handleLogoutEvent ()
 reset sessions type to unknown More...
 
static getExistingSessionCount (array $a_types)
 
static getSettingFields ()
 

Data Fields

const int DEFAULT_MIN_IDLE = 15
 default value for settings that have not been defined in setup or administration yet More...
 
const int DEFAULT_ALLOW_CLIENT_MAINTENANCE = 1
 

Static Public Attributes

static array $session_types_controlled
 

Static Private Member Functions

static isValidSession (string $a_sid)
 
static removeSessionCookie ()
 
static checkAdministrationPermission (int $a_user_id)
 
static debug (string $a_debug_log_message)
 

Private Attributes

const int SESSION_TYPE_UNKNOWN = 0
 session types from which one is assigned to each session More...
 
const int SESSION_TYPE_SYSTEM = 1
 
const int SESSION_TYPE_ADMIN = 2
 
const int SESSION_TYPE_USER = 3
 
const int SESSION_TYPE_ANONYM = 4
 
const string SESSION_TYPE_KEY = 'SessionType'
 

Static Private Attributes

static array $setting_fields
 
static array $session_types_not_controlled
 all session types that will be involved when count of sessions will be determined or when idleing sessions will be destroyed More...
 

Detailed Description

Definition at line 21 of file class.ilSessionControl.php.

Member Function Documentation

◆ checkAdministrationPermission()

static ilSessionControl::checkAdministrationPermission ( int  $a_user_id)
staticprivate

Definition at line 166 of file class.ilSessionControl.php.

References $DIC, and SYSTEM_FOLDER_ID.

166  : bool
167  {
168  if (!$a_user_id) {
169  return false;
170  }
171 
172  global $DIC;
173 
174  $rbacsystem = $DIC['rbacsystem'];
175 
176  $access = $rbacsystem->checkAccessOfUser(
177  $a_user_id,
178  'read,visible',
180  );
181 
182  return $access;
183  }
const SYSTEM_FOLDER_ID
Definition: constants.php:35
global $DIC
Definition: shib_login.php:26

◆ debug()

static ilSessionControl::debug ( string  $a_debug_log_message)
staticprivate

Definition at line 185 of file class.ilSessionControl.php.

References $DIC.

185  : void
186  {
187  global $DIC;
188 
189  $logger = $DIC->logger()->auth();
190 
191  $logger->debug($a_debug_log_message);
192  }
global $DIC
Definition: shib_login.php:26

◆ getExistingSessionCount()

static ilSessionControl::getExistingSessionCount ( array  $a_types)
static
Parameters
list<int>$a_types

Definition at line 105 of file class.ilSessionControl.php.

References $DIC, $ilDB, $res, and ilDBConstants\FETCHMODE_OBJECT.

Referenced by ilSessionStatisticsGUI\renderCurrentBasics().

105  : int
106  {
107  global $DIC;
108 
109  $ilDB = $DIC['ilDB'];
110 
111  $ts = time();
112 
113  $query = 'SELECT count(session_id) AS num_sessions FROM usr_session ' .
114  'WHERE expires > %s ' .
115  'AND ' . $ilDB->in('type', $a_types, false, 'integer');
116 
117  $res = $ilDB->queryF($query, ['integer'], [$ts]);
118  return (int) $res->fetchRow(ilDBConstants::FETCHMODE_OBJECT)->num_sessions;
119  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26
+ Here is the caller graph for this function:

◆ getSettingFields()

static ilSessionControl::getSettingFields ( )
static
Returns
list<string>

Definition at line 197 of file class.ilSessionControl.php.

197  : array
198  {
199  return self::$setting_fields;
200  }

◆ handleLoginEvent()

static ilSessionControl::handleLoginEvent ( string  $a_login,
ilAuthSession  $auth_session 
)
static

Definition at line 65 of file class.ilSessionControl.php.

References $user_id, ilObjUser\_lookupId(), ANONYMOUS_USER_ID, and ilSession\set().

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

65  : bool
66  {
67  $user_id = ilObjUser::_lookupId($a_login);
68 
69  // we need the session type for the session statistics
70  // regardless of the current session handling type
71  switch (true) {
72  case isset($_ENV['SHELL']):
73  $type = self::SESSION_TYPE_SYSTEM;
74  break;
75 
76  case $user_id === ANONYMOUS_USER_ID:
77  $type = self::SESSION_TYPE_ANONYM;
78  break;
79 
80  case self::checkAdministrationPermission($user_id):
81  $type = self::SESSION_TYPE_ADMIN;
82  break;
83 
84  default:
85  $type = self::SESSION_TYPE_USER;
86  break;
87  }
88 
89  ilSession::set(self::SESSION_TYPE_KEY, $type);
90  self::debug(__METHOD__ . ' --> update sessions type to (' . $type . ')');
91 
92  return true;
93  }
const ANONYMOUS_USER_ID
Definition: constants.php:27
static _lookupId($a_user_str)
static set(string $a_var, $a_val)
Set a value.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ handleLogoutEvent()

static ilSessionControl::handleLogoutEvent ( )
static

reset sessions type to unknown

Definition at line 98 of file class.ilSessionControl.php.

98  : void
99  {
100  }

◆ isValidSession()

static ilSessionControl::isValidSession ( string  $a_sid)
staticprivate

Definition at line 121 of file class.ilSessionControl.php.

References $DIC, $ilDB, and $res.

121  : bool
122  {
123  global $DIC;
124 
125  $ilDB = $DIC['ilDB'];
126 
127  $query = 'SELECT session_id, expires FROM usr_session ' .
128  'WHERE session_id = %s';
129 
130  $res = $ilDB->queryF($query, ['text'], [$a_sid]);
131 
132  $ts = time();
133 
134  $sessions = [];
135 
136  while ($row = $ilDB->fetchAssoc($res)) {
137  if ($row['expires'] > $ts) {
138  self::debug(__METHOD__ . ' --> Found a valid session with id (' . $a_sid . ')');
139  $sessions[] = $row;
140  } else {
141  self::debug(__METHOD__ . ' --> Found an expired session with id (' . $a_sid . ')');
142  }
143  }
144 
145  if (count($sessions) === 1) {
146  self::debug(__METHOD__ . ' --> Exact one valid session found for session id (' . $a_sid . ')');
147 
148  return true;
149  }
150 
151  if (count($sessions) > 1) {
152  self::debug(__METHOD__ . ' --> Strange!!! More than one sessions found for given session id! (' . $a_sid . ')');
153  } else {
154  self::debug(__METHOD__ . ' --> No valid session found for session id (' . $a_sid . ')');
155  }
156 
157  return false;
158  }
$res
Definition: ltiservices.php:66
global $DIC
Definition: shib_login.php:26

◆ removeSessionCookie()

static ilSessionControl::removeSessionCookie ( )
staticprivate

Definition at line 160 of file class.ilSessionControl.php.

References ilUtil\setCookie().

160  : void
161  {
162  ilUtil::setCookie(session_name(), 'deleted', true, true);
163  self::debug('Session cookie has been removed');
164  }
static setCookie(string $a_cookie_name, string $a_cookie_value='', bool $a_also_set_super_global=true, bool $a_set_cookie_invalid=false)
+ Here is the call graph for this function:

Field Documentation

◆ $session_types_controlled

array ilSessionControl::$session_types_controlled
static
Initial value:
= [
self::SESSION_TYPE_USER,
self::SESSION_TYPE_ANONYM
]

Definition at line 54 of file class.ilSessionControl.php.

Referenced by ilSessionStatistics\getNumberOfActiveRawSessions(), ilSessionStatistics\getRawData(), ilSession\lookupExpireTime(), and ilSessionStatisticsGUI\renderCurrentBasics().

◆ $session_types_not_controlled

array ilSessionControl::$session_types_not_controlled
staticprivate
Initial value:
= [
self::SESSION_TYPE_UNKNOWN,
self::SESSION_TYPE_SYSTEM,
self::SESSION_TYPE_ADMIN
]

all session types that will be involved when count of sessions will be determined or when idleing sessions will be destroyed

Definition at line 59 of file class.ilSessionControl.php.

◆ $setting_fields

list< string > ilSessionControl::$setting_fields
staticprivate
Initial value:
= [
'session_allow_client_maintenance',
]

Definition at line 33 of file class.ilSessionControl.php.

◆ DEFAULT_ALLOW_CLIENT_MAINTENANCE

const int ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE = 1

◆ DEFAULT_MIN_IDLE

const int ilSessionControl::DEFAULT_MIN_IDLE = 15

default value for settings that have not been defined in setup or administration yet

Definition at line 27 of file class.ilSessionControl.php.

Referenced by ilObjSCORMInitData\getIliasScormVars(), and ilSCORM13PlayerGUI\getPlayer().

◆ SESSION_TYPE_ADMIN

const int ilSessionControl::SESSION_TYPE_ADMIN = 2
private

Definition at line 43 of file class.ilSessionControl.php.

◆ SESSION_TYPE_ANONYM

const int ilSessionControl::SESSION_TYPE_ANONYM = 4
private

Definition at line 45 of file class.ilSessionControl.php.

◆ SESSION_TYPE_KEY

const string ilSessionControl::SESSION_TYPE_KEY = 'SessionType'
private

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

◆ SESSION_TYPE_SYSTEM

const int ilSessionControl::SESSION_TYPE_SYSTEM = 1
private

Definition at line 42 of file class.ilSessionControl.php.

◆ SESSION_TYPE_UNKNOWN

const int ilSessionControl::SESSION_TYPE_UNKNOWN = 0
private

session types from which one is assigned to each session

Definition at line 41 of file class.ilSessionControl.php.

◆ SESSION_TYPE_USER

const int ilSessionControl::SESSION_TYPE_USER = 3
private

Definition at line 44 of file class.ilSessionControl.php.


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