本文整理汇总了PHP中wp_destroy_current_session函数的典型用法代码示例。如果您正苦于以下问题:PHP wp_destroy_current_session函数的具体用法?PHP wp_destroy_current_session怎么用?PHP wp_destroy_current_session使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了wp_destroy_current_session函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: pcl_prevent_concurrent_logins
/**
* Only allow one session per user
*
* If the current user's session has been taken over by a newer
* session then we will destroy their session automattically and
* they will have to login again to continue.
*
* @action init
*/
function pcl_prevent_concurrent_logins()
{
if (!pcl_user_has_concurrent_sessions()) {
return;
}
$user_id = get_current_user_id();
/**
* Filter to allow certain users to have concurrent sessions when necessary
*
* @since 0.1.1
*
* @param bool $prevent
* @param int $user_id ID of the current user
*
* @return bool
*/
if (false === (bool) apply_filters('pcl_prevent_concurrent_logins', true, $user_id)) {
return;
}
$newest = max(wp_list_pluck(wp_get_all_sessions(), 'login'));
$session = pcl_get_current_session();
if ($session['login'] === $newest) {
wp_destroy_other_sessions();
/**
* Fires after a user's non-current sessions are destroyed
*
* @since 0.3.0
*
* @param int $user_id ID of the affected user
*/
do_action('pcl_destroy_other_sessions', $user_id);
} else {
wp_destroy_current_session();
/**
* Fires after a user's current session is destroyed
*
* @since 0.3.0
*
* @param int $user_id ID of the affected user
*/
do_action('pcl_destroy_current_session', $user_id);
}
}
示例2: wp_logout
/**
* Log the current user out.
*
* @since 2.5.0
*/
function wp_logout()
{
wp_destroy_current_session();
wp_clear_auth_cookie();
/**
* Fires after a user is logged-out.
*
* @since 1.5.0
*/
do_action('wp_logout');
}
示例3: pc_logout
function pc_logout()
{
global $pc_users;
if (isset($_SESSION['pc_user_id'])) {
unset($_SESSION['pc_user_id']);
}
if (isset($GLOBALS['pc_user_id'])) {
unset($GLOBALS['pc_user_id']);
}
setcookie('pc_user', '', time() - 3600 * 25, '/');
$wp_user_id = pc_user_logged('wp_user_id');
if ($wp_user_id !== false) {
// wp user sync - unlog if WP logged is the one synced
if ($pc_users->wp_user_sync) {
$current_user = wp_get_current_user();
if ($current_user && $wp_user_id == $current_user->ID) {
wp_destroy_current_session();
setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, ADMIN_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, PLUGINS_COOKIE_PATH, COOKIE_DOMAIN);
setcookie(LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
setcookie(LOGGED_IN_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
// Old cookies
setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
setcookie(AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
setcookie(SECURE_AUTH_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
// Even older cookies
setcookie(USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, COOKIEPATH, COOKIE_DOMAIN);
setcookie(USER_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
setcookie(PASS_COOKIE, ' ', time() - YEAR_IN_SECONDS, SITECOOKIEPATH, COOKIE_DOMAIN);
//wp_clear_auth_cookie(); // don't use the function to avoid interferences with do_action( 'clear_auth_cookie' );
}
}
// PC-ACTION - user is logged out - passes user id
do_action('pc_user_logout', $GLOBALS['PC_VER_LOGGED_USER']);
unset($GLOBALS['PC_VER_LOGGED_USER']);
}
return true;
}
示例4: oxd_openid_logout_validate
function oxd_openid_logout_validate()
{
if (isset($_REQUEST['option']) and strpos($_REQUEST['option'], 'allLogout') !== false && !isset($_REQUEST['state'])) {
echo '<script>
var delete_cookie = function(name) {
document.cookie = name + \'=;expires=Thu, 01 Jan 1970 00:00:01 GMT;\';
};
delete_cookie(\'user_oxd_access_token\');
delete_cookie(\'user_oxd_id_token\');
delete_cookie(\'session_states\');
delete_cookie(\'states\');
</script>';
wp_destroy_current_session();
wp_clear_auth_cookie();
wp_logout();
}
}
开发者ID:GluuFederation,项目名称:gluu-wordpress-sso-login-plugin,代码行数:17,代码来源:class-oxd-openid-login-widget.php