本文整理汇总了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
示例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;
}
示例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));
}
示例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);