當前位置: 首頁>>代碼示例>>PHP>>正文


PHP wp_destroy_current_session函數代碼示例

本文整理匯總了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);
    }
}
開發者ID:n0risc,項目名稱:prevent-concurrent-logins,代碼行數:52,代碼來源:prevent-concurrent-logins.php

示例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');
 }
開發者ID:cybKIRA,項目名稱:roverlink-updated,代碼行數:16,代碼來源:pluggable.php

示例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;
}
開發者ID:jfbelisle,項目名稱:magexpress,代碼行數:42,代碼來源:public_api.php

示例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


注:本文中的wp_destroy_current_session函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。