Un motore di ricerca WordPress per sviluppatori e autori di temi



wp_parse_auth_cookie ›

Da2.7.0
Deprecaton/a
wp_parse_auth_cookie ( $cookie = '', $scheme = '' )
Parametri: (2)
  • (string) $cookie Authentication cookie.
    Richiesto: No
    Default: (vuoto)
  • (string) $scheme Optional. The cookie scheme to use: 'auth', 'secure_auth', or 'logged_in'.
    Richiesto: No
    Default: (vuoto)
Ritorna:
  • (array|false) Authentication cookie components.
Definito a:
Codex:

Parses a cookie into its components.



Sorgenti

function wp_parse_auth_cookie( $cookie = '', $scheme = '' ) {
		if ( empty( $cookie ) ) {
			switch ( $scheme ) {
				case 'auth':
					$cookie_name = AUTH_COOKIE;
					break;
				case 'secure_auth':
					$cookie_name = SECURE_AUTH_COOKIE;
					break;
				case 'logged_in':
					$cookie_name = LOGGED_IN_COOKIE;
					break;
				default:
					if ( is_ssl() ) {
						$cookie_name = SECURE_AUTH_COOKIE;
						$scheme      = 'secure_auth';
					} else {
						$cookie_name = AUTH_COOKIE;
						$scheme      = 'auth';
					}
			}

			if ( empty( $_COOKIE[ $cookie_name ] ) ) {
				return false;
			}
			$cookie = $_COOKIE[ $cookie_name ];
		}

		$cookie_elements = explode( '|', $cookie );
		if ( count( $cookie_elements ) !== 4 ) {
			return false;
		}

		list( $username, $expiration, $token, $hmac ) = $cookie_elements;

		return compact( 'username', 'expiration', 'token', 'hmac', 'scheme' );
	}
endif;

if ( ! function_exists( 'wp_set_auth_cookie' ) ) :