ILIAS  trunk Revision v11.0_alpha-3011-gc6b235a2e85
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.

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

References $DIC, and SYSTEM_FOLDER_ID.

Referenced by handleLoginEvent().

+ Here is the caller graph for this function:

◆ debug()

static ilSessionControl::debug ( string  $a_debug_log_message)
staticprivate

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

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

References $DIC.

Referenced by handleLoginEvent(), isValidSession(), and removeSessionCookie().

+ Here is the caller graph for this function:

◆ getExistingSessionCount()

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

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

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:69

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

Referenced by ilSessionStatisticsGUI\renderCurrentBasics().

+ 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 {
200 }

References $setting_fields.

◆ handleLoginEvent()

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

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

65 : bool
66 {
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
78 break;
79
81 $type = self::SESSION_TYPE_ADMIN;
82 break;
83
84 default:
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 }
static _lookupId(string|array $a_user_str)
static checkAdministrationPermission(int $a_user_id)
static debug(string $a_debug_log_message)
static set(string $a_var, $a_val)
Set a value.
const ANONYMOUS_USER_ID
Definition: constants.php:27

References $user_id, ilObjUser\_lookupId(), ANONYMOUS_USER_ID, checkAdministrationPermission(), debug(), SESSION_TYPE_ADMIN, SESSION_TYPE_ANONYM, SESSION_TYPE_SYSTEM, SESSION_TYPE_USER, and ilSession\set().

Referenced by ilAuthFrontend\handleAuthenticationSuccess().

+ 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.

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 }

References $DIC, $ilDB, $res, and debug().

+ Here is the call graph for this function:

◆ removeSessionCookie()

static ilSessionControl::removeSessionCookie ( )
staticprivate

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

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)

References debug(), and ilUtil\setCookie().

+ Here is the call graph for this function:

Field Documentation

◆ $session_types_controlled

array ilSessionControl::$session_types_controlled
static

◆ $session_types_not_controlled

array ilSessionControl::$session_types_not_controlled
staticprivate
Initial value:
= [
]
const int SESSION_TYPE_UNKNOWN
session types from which one is assigned to each session

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.

Referenced by getSettingFields().

◆ DEFAULT_ALLOW_CLIENT_MAINTENANCE

const int ilSessionControl::DEFAULT_ALLOW_CLIENT_MAINTENANCE = 1

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

◆ 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.

Referenced by handleLoginEvent().

◆ SESSION_TYPE_ANONYM

const int ilSessionControl::SESSION_TYPE_ANONYM = 4
private

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

Referenced by handleLoginEvent().

◆ 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.

Referenced by handleLoginEvent().

◆ 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.

Referenced by handleLoginEvent().


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