当前位置: 首页>>代码示例>>PHP>>正文


PHP session_gc函数代码示例

本文整理汇总了PHP中session_gc函数的典型用法代码示例。如果您正苦于以下问题:PHP session_gc函数的具体用法?PHP session_gc怎么用?PHP session_gc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了session_gc函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: cron_run


//.........这里部分代码省略.........
        if (!empty($CFG->usetags)) {
            require_once $CFG->dirroot . '/tag/lib.php';
            tag_cron();
            mtrace(' Executed tag cron');
        }
        // Context maintenance stuff
        context_helper::cleanup_instances();
        mtrace(' Cleaned up context instances');
        context_helper::build_all_paths(false);
        // If you suspect that the context paths are somehow corrupt
        // replace the line below with: context_helper::build_all_paths(true);
        mtrace(' Built context paths');
        // Remove expired cache flags
        gc_cache_flags();
        mtrace(' Cleaned cache flags');
        // Cleanup messaging
        if (!empty($CFG->messagingdeletereadnotificationsdelay)) {
            $notificationdeletetime = time() - $CFG->messagingdeletereadnotificationsdelay;
            $DB->delete_records_select('message_read', 'notification=1 AND timeread<:notificationdeletetime', array('notificationdeletetime' => $notificationdeletetime));
            mtrace(' Cleaned up read notifications');
        }
        mtrace("...finished clean-up tasks");
    }
    // End of occasional clean-up tasks
    // Send login failures notification - brute force protection in moodle is weak,
    // we should at least send notices early in each cron execution
    if (notify_login_failures()) {
        mtrace(' Notified login failures');
    }
    // Make sure all context instances are properly created - they may be required in auth, enrol, etc.
    context_helper::create_instances();
    mtrace(' Created missing context instances');
    // Session gc
    session_gc();
    mtrace("Cleaned up stale user sessions");
    // Run the auth cron, if any before enrolments
    // because it might add users that will be needed in enrol plugins
    $auths = get_enabled_auth_plugins();
    mtrace("Running auth crons if required...");
    foreach ($auths as $auth) {
        $authplugin = get_auth_plugin($auth);
        if (method_exists($authplugin, 'cron')) {
            mtrace("Running cron for auth/{$auth}...");
            $authplugin->cron();
            if (!empty($authplugin->log)) {
                mtrace($authplugin->log);
            }
        }
        unset($authplugin);
    }
    // Generate new password emails for users - ppl expect these generated asap
    if ($DB->count_records('user_preferences', array('name' => 'create_password', 'value' => '1'))) {
        mtrace('Creating passwords for new users...');
        $newusers = $DB->get_recordset_sql("SELECT u.id as id, u.email, u.firstname,\n                                                 u.lastname, u.username, u.lang,\n                                                 p.id as prefid\n                                            FROM {user} u\n                                            JOIN {user_preferences} p ON u.id=p.userid\n                                           WHERE p.name='create_password' AND p.value='1' AND u.email !='' AND u.suspended = 0 AND u.auth != 'nologin' AND u.deleted = 0");
        // note: we can not send emails to suspended accounts
        foreach ($newusers as $newuser) {
            if (setnew_password_and_mail($newuser)) {
                unset_user_preference('create_password', $newuser);
                set_user_preference('auth_forcepasswordchange', 1, $newuser);
            } else {
                trigger_error("Could not create and mail new user password!");
            }
        }
        $newusers->close();
    }
    // It is very important to run enrol early
开发者ID:saurabh947,项目名称:MoodleLearning,代码行数:67,代码来源:cronlib.php

示例2: handler_gc

 /**
  * GC session handler
  *
  * {@see http://php.net/manual/en/function.session-set-save-handler.php}
  *
  * @param int $ignored_maxlifetime moodle uses special timeout rules
  * @return bool success
  */
 public function handler_gc($ignored_maxlifetime)
 {
     session_gc();
     return true;
 }
开发者ID:neogic,项目名称:moodle,代码行数:13,代码来源:sessionlib.php

示例3: set_config

         set_config('auth', implode(',', $authsenabled));
     }
     if ($auth == $CFG->registerauth) {
         set_config('registerauth', '');
     }
     session_gc();
     // remove stale sessions
     break;
 case 'enable':
     // add to enabled list
     if (!in_array($auth, $authsenabled)) {
         $authsenabled[] = $auth;
         $authsenabled = array_unique($authsenabled);
         set_config('auth', implode(',', $authsenabled));
     }
     session_gc();
     // remove stale sessions
     break;
 case 'down':
     $key = array_search($auth, $authsenabled);
     // check auth plugin is valid
     if ($key === false) {
         print_error('pluginnotenabled', 'auth', $url, $auth);
     }
     // move down the list
     if ($key < count($authsenabled) - 1) {
         $fsave = $authsenabled[$key];
         $authsenabled[$key] = $authsenabled[$key + 1];
         $authsenabled[$key + 1] = $fsave;
         set_config('auth', implode(',', $authsenabled));
     }
开发者ID:nicolasconnault,项目名称:moodle2.0,代码行数:31,代码来源:auth.php

示例4: profile_load_custom_fields

            $USER->$variable = $value;
        }
        // preload custom fields
        profile_load_custom_fields($USER);

        if (!empty($USER->newadminuser)) {
            unset($USER->newadminuser);
            // apply defaults again - some of them might depend on admin user info, backup, roles, etc.
            admin_apply_default_settings(NULL , false);
            // redirect to admin/ to continue with installation
            redirect("$CFG->wwwroot/$CFG->admin/");
        } else {
            redirect("$CFG->wwwroot/user/view.php?id=$USER->id&course=$course->id");
        }
    } else {
        session_gc(); // remove stale sessions
        redirect("$CFG->wwwroot/$CFG->admin/user.php");
    }
    //never reached
}

// make sure we really are on the https page when https login required
$PAGE->verify_https_required();


/// Display page header
if ($user->id == -1 or ($user->id != $USER->id)) {
    if ($user->id == -1) {
        echo $OUTPUT->header();
    } else {
        $PAGE->set_heading($SITE->fullname);
开发者ID:nfreear,项目名称:moodle,代码行数:31,代码来源:editadvanced.php


注:本文中的session_gc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。