本文整理汇总了PHP中Core\Session\manager::kill_session方法的典型用法代码示例。如果您正苦于以下问题:PHP manager::kill_session方法的具体用法?PHP manager::kill_session怎么用?PHP manager::kill_session使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Core\Session\manager
的用法示例。
在下文中一共展示了manager::kill_session方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: report_usersessions_kill_session
/**
* Kill user session.
*
* @param int $id
* @return void
*/
function report_usersessions_kill_session($id)
{
global $DB, $USER;
$session = $DB->get_record('sessions', array('id' => $id, 'userid' => $USER->id), 'id, sid');
if (!$session or $session->sid === session_id()) {
// Do not delete the current session!
return;
}
\core\session\manager::kill_session($session->sid);
}
示例2: session_kill
/**
* Terminates one sessions, auth hooks are not executed.
*
* @deprecated since 2.6
* @param string $sid session id
*/
function session_kill($sid)
{
debugging('session_kill() is deprecated, use \\core\\session\\manager::kill_session() instead', DEBUG_DEVELOPER);
\core\session\manager::kill_session($sid);
}
示例3: while
/**
* To delete a host, we must delete all current sessions that users from
* that host are currently engaged in.
*
* @param string $sessionidarray An array of session hashes
* @return bool True on success
*/
function end_local_sessions(&$sessionArray)
{
global $CFG;
if (is_array($sessionArray)) {
while ($session = array_pop($sessionArray)) {
\core\session\manager::kill_session($session->session_id);
}
return true;
}
return false;
}
示例4: test_kill_session
public function test_kill_session()
{
global $DB, $USER;
$this->resetAfterTest();
$this->setAdminUser();
$userid = $USER->id;
$sid = md5('hokus');
$record = new \stdClass();
$record->state = 0;
$record->sid = $sid;
$record->sessdata = null;
$record->userid = $userid;
$record->timecreated = time() - 60 * 60;
$record->timemodified = time() - 30;
$record->firstip = $record->lastip = '10.0.0.1';
$DB->insert_record('sessions', $record);
$record->userid = 0;
$record->sid = md5('pokus');
$DB->insert_record('sessions', $record);
$this->assertEquals(2, $DB->count_records('sessions'));
\core\session\manager::kill_session($sid);
$this->assertEquals(1, $DB->count_records('sessions'));
$this->assertFalse($DB->record_exists('sessions', array('sid' => $sid)));
$this->assertSame($userid, $USER->id);
}