38        'session_max_idle_after_first_request',
 
   39        'session_allow_client_maintenance',
 
   40        'session_handling_type' 
   60        self::SESSION_TYPE_USER,
 
   61        self::SESSION_TYPE_ANONYM
 
   71        self::SESSION_TYPE_UNKNOWN,
 
   72        self::SESSION_TYPE_SYSTEM,
 
   73        self::SESSION_TYPE_ADMIN
 
   92        if (
$ilSetting->get(
'session_handling_type', 0) != 1) {
 
  110            if (!isset(
$_COOKIE[session_name()]) || !strlen(
$_COOKIE[session_name()])) {
 
  115                self::debug(
'Browser sent sid cookie with value (' . $sid . 
')');
 
  118                    self::debug(
'remove session cookie for (' . $sid . 
') and trigger event');
 
  127                    $ilAppEventHandler = 
$DIC[
'ilAppEventHandler'];
 
  128                    $ilAppEventHandler->raise(
 
  129                        'Services/Authentication',
 
  130                        'expiredSessionDetected',
 
  151        if (
$ilSetting->get(
'session_handling_type', 0) != 1) {
 
  174        require_once 
'Services/User/classes/class.ilObjUser.php';
 
  180            case isset($_ENV[
'SHELL']):
 
  184            case $user_id == ANONYMOUS_USER_ID:
 
  201        if (
$ilSetting->get(
'session_handling_type', 0) != 1) {
 
  205        if (in_array(
$type, self::$session_types_controlled)) {
 
  220        if (
$ilSetting->get(
'session_handling_type', 0) != 1) {
 
  248        $max_sessions = (int) 
$ilSetting->get(
'session_max_count', self::DEFAULT_MAX_COUNT);
 
  250        if ($max_sessions > 0) {
 
  254            self::debug(__METHOD__ . 
"--> total existing sessions (" . $num_sessions . 
")");
 
  256            if (($num_sessions + 1) > $max_sessions) {
 
  257                self::debug(__METHOD__ . 
' --> limit for session pool reached, but try kicking some first request abidencer');
 
  264                if (($num_sessions + 1) > $max_sessions) {
 
  265                    self::debug(__METHOD__ . 
' --> limit for session pool still reached so try kick one min idle session');
 
  272                    if (($num_sessions + 1) > $max_sessions) {
 
  273                        self::debug(__METHOD__ . 
' --> limit for session pool still reached so logout session (' . session_id() . 
') and trigger event');
 
  291                        $ilAppEventHandler = 
$DIC[
'ilAppEventHandler'];
 
  292                        $ilAppEventHandler->raise(
 
  293                            'Services/Authentication',
 
  294                            'reachedSessionPoolLimit',
 
  304                        self::debug(__METHOD__ . 
' --> limit of session pool not reached anymore after kicking one min idle session');
 
  307                    self::debug(__METHOD__ . 
' --> limit of session pool not reached anymore after kicking some first request abidencer');
 
  310                self::debug(__METHOD__ . 
' --> limit for session pool not reached yet');
 
  313            self::debug(__METHOD__ . 
' --> limit for session pool not set so check is bypassed');
 
  332        $query = 
"SELECT count(session_id) AS num_sessions FROM usr_session " .
 
  333                    "WHERE expires > %s " .
 
  334                    "AND " . 
$ilDB->in(
'type', $a_types, 
false, 
'integer');
 
  339        return $row->num_sessions;
 
  360        $min_idle = (int) 
$ilSetting->get(
'session_min_idle', self::DEFAULT_MIN_IDLE) * 60;
 
  361        $max_idle = (int) 
$ilSetting->get(
'session_max_idle', self::DEFAULT_MAX_IDLE) * 60;
 
  363        $query = 
"SELECT session_id,expires FROM usr_session WHERE expires >= %s " .
 
  364                "AND (expires - %s) < (%s - %s) " .
 
  365                "AND " . 
$ilDB->in(
'type', $a_types, 
false, 
'integer') . 
" ORDER BY expires";
 
  369            array(
'integer', 
'integer', 
'integer', 
'integer'),
 
  370            array($ts, $ts, $max_idle, $min_idle)
 
  376            self::debug(__METHOD__ . 
' --> successfully deleted one min idle session');
 
  381        self::debug(__METHOD__ . 
' --> no min idle session available for deletion');
 
  401        $max_idle_after_first_request = (int) 
$ilSetting->get(
'session_max_idle_after_first_request') * 60;
 
  403        if ((
int) $max_idle_after_first_request == 0) {
 
  407        $query = 
"SELECT session_id,expires FROM usr_session WHERE " .
 
  408                "(ctime - createtime) < %s " .
 
  409                "AND (%s - createtime) > %s " .
 
  410                "AND " . 
$ilDB->in(
'type', $a_types, 
false, 
'integer');
 
  414            array(
'integer', 
'integer', 
'integer'),
 
  415            array($max_idle_after_first_request, time(), $max_idle_after_first_request)
 
  418        $session_ids = array();
 
  420            $session_ids[
$row->session_id] = 
$row->expires;
 
  424        self::debug(__METHOD__ . 
' --> Finished kicking first request abidencer');
 
  443        $query = 
"SELECT session_id, expires FROM usr_session " .
 
  444                    "WHERE session_id = %s";
 
  453            if (
$row[
'expires'] > $ts) {
 
  454                self::debug(__METHOD__ . 
' --> Found a valid session with id (' . $a_sid . 
')');
 
  457                self::debug(__METHOD__ . 
' --> Found an expired session with id (' . $a_sid . 
')');
 
  461        if (count($sessions) == 1) {
 
  462            self::debug(__METHOD__ . 
' --> Exact one valid session found for session id (' . $a_sid . 
')');
 
  466            if (count($sessions) > 1) {
 
  467                self::debug(__METHOD__ . 
' --> Strange!!! More than one sessions found for given session id! (' . $a_sid . 
')');
 
  469                self::debug(__METHOD__ . 
' --> No valid session found for session id (' . $a_sid . 
')');
 
  495        if (!(
int) $a_user_id) {
 
  501        $rbacsystem = 
$DIC[
'rbacsystem'];
 
  503        $access = $rbacsystem->checkAccessOfUser(
 
  518    private static function debug($a_debug_log_message)
 
  525            $ilLog->write($a_debug_log_message, 
'message');
 
  528        if (self::INTERNAL_DEBUG) {
 
  529            error_log($a_debug_log_message . 
"\n", 3, 
'session.log');
 
An exception for terminatinating execution or to throw for unit testing.
isValidSession($ext_uid, $soap_pw, $new_user)
isValidSession
static _lookupId($a_user_str)
Lookup id by login.
const INTERNAL_DEBUG
this controls the debuggin into a separate logfile (.
static handleLogoutEvent()
reset sessions type to unknown
static isValidSession($a_sid)
checks if session exists for given id and if it is still valid
static $session_types_not_controlled
all session types that will be involved when count of sessions will be determined or when idleing ses...
static initSession()
mark session with type regarding to the context.
static $setting_fields
all fieldnames that are saved in settings table
static $session_types_controlled
const SESSION_TYPE_UNKNOWN
session types from which one is assigned to each session
static getSettingFields()
returns the array of setting fields
static handleLoginEvent($a_login, ilAuthSession $auth_session)
when current session is allowed to be created it marks it with type regarding to the sessions user co...
const DEFAULT_MAX_IDLE_AFTER_FIRST_REQUEST
static checkExpiredSession()
checks for possibly expired session should be called from ilAuthUtils::__initAuth() so it's called be...
static debug($a_debug_log_message)
logs the given debug message in ilLog
static getExistingSessionCount(array $a_types)
returns number of valid sessions relating to given session types
const DEFAULT_ALLOW_CLIENT_MAINTENANCE
static checkCurrentSessionIsAllowed(ilAuthSession $auth, $a_user_id)
checks wether the current session exhaust the limit of sessions when limit is reached it deletes "fir...
static removeSessionCookie()
removes a session cookie, so it is not sent by browser anymore
const DEFAULT_MAX_COUNT
default value for settings that have not been defined in setup or administration yet
static checkAdministrationPermission($a_user_id)
checks wether a given user login relates to an user with administrative permissions
static kickOneMinIdleSession(array $a_types)
if sessions exist that relates to given session types and idled longer than min idle parameter,...
const SESSION_TYPE_ANONYM
const SESSION_TYPE_SYSTEM
static kickFirstRequestAbidencer(array $a_types)
kicks sessions of users that abidence after login so people could not login and go for coffe break ;-...
static createRawEntry($a_session_id, $a_session_type, $a_timestamp, $a_user_id)
Create raw data entry.
static setClosingContext($a_context)
set closing context (for statistics)
static _destroy($a_session_id, $a_closing_context=null, $a_expired_at=null)
Destroy session.
const SESSION_CLOSE_FIRST
const SESSION_CLOSE_LIMIT
static setCookie($a_cookie_name, $a_cookie_value='', $a_also_set_super_global=true, $a_set_cookie_invalid=false)
static redirect($a_script)
foreach($_POST as $key=> $value) $res