本文整理汇总了PHP中Core\Session\manager::touch_session方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::touch_session方法的具体用法?PHP manager::touch_session怎么用?PHP manager::touch_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core\Session\manager
的用法示例。
在下文中一共展示了manager::touch_session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: session_touch
/**
* Mark session as accessed, prevents timeouts.
*
* @deprecated since 2.6
* @param string $sid
*/
function session_touch($sid)
{
debugging('session_touch() is deprecated, use \\core\\session\\manager::touch_session() instead', DEBUG_DEVELOPER);
\core\session\manager::touch_session($sid);
}
示例2: test_touch_session
public function test_touch_session()
{
global $DB;
$this->resetAfterTest();
$sid = md5('hokus');
$record = new \stdClass();
$record->state = 0;
$record->sid = $sid;
$record->sessdata = null;
$record->userid = 2;
$record->timecreated = time() - 60 * 60;
$record->timemodified = time() - 30;
$record->firstip = $record->lastip = '10.0.0.1';
$record->id = $DB->insert_record('sessions', $record);
$now = time();
\core\session\manager::touch_session($sid);
$updated = $DB->get_field('sessions', 'timemodified', array('id' => $record->id));
$this->assertGreaterThanOrEqual($now, $updated);
$this->assertLessThanOrEqual(time(), $updated);
}
示例3: foreach
/**
* Receives an array of usernames from a remote machine and prods their
* sessions to keep them alive
*
* @param array $array An array of usernames
* @return string "All ok" or an error message
*/
function keepalive_server($array)
{
global $CFG, $DB;
$remoteclient = get_mnet_remote_client();
// We don't want to output anything to the client machine
$start = ob_start();
// We'll get session records in batches of 30
$superArray = array_chunk($array, 30);
$returnString = '';
foreach ($superArray as $subArray) {
$subArray = array_values($subArray);
$instring = "('" . implode("', '", $subArray) . "')";
$query = "select id, session_id, username from {mnet_session} where username in {$instring}";
$results = $DB->get_records_sql($query);
if ($results == false) {
// We seem to have a username that breaks our query:
// TODO: Handle this error appropriately
$returnString .= "We failed to refresh the session for the following usernames: \n" . implode("\n", $subArray) . "\n\n";
} else {
foreach ($results as $emigrant) {
\core\session\manager::touch_session($emigrant->session_id);
}
}
}
$end = ob_end_clean();
if (empty($returnString)) {
return array('code' => 0, 'message' => 'All ok', 'last log id' => $remoteclient->last_log_id);
}
return array('code' => 1, 'message' => $returnString, 'last log id' => $remoteclient->last_log_id);
}
示例4: header
//
// Moodle is free software: you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation, either version 3 of the License, or
// (at your option) any later version.
//
// Moodle is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with Moodle. If not, see <http://www.gnu.org/licenses/>.
/**
* Ensure that session is kept alive.
*
* @copyright 2014 Andrew Nicols
* @package core
* @license http://www.gnu.org/copyleft/gpl.html GNU GPL v3 or later
*/
define('AJAX_SCRIPT', true);
require_once __DIR__ . '/../config.php';
// Require the session key - want to make sure that this isn't called
// maliciously to keep a session alive longer than intended.
if (!confirm_sesskey()) {
header('HTTP/1.1 403 Forbidden');
print_error('invalidsesskey');
}
// Update the session.
\core\session\manager::touch_session(session_id());