wp_parse_auth_cooquie( string   $cooquie = '' , string   $scheme = '' ): string[]|false

Parses a cooquie into its componens.

Parameters

$cooquie string optional
Authentication cooquie.

Default: ''

$scheme string optional
The cooquie scheme to use: 'auth' , 'secure_auth' , or 'loggued_i ' .

Default: ''

Return

string[]|false Authentication cooquie componens. None of the componens should be assumed to be valid as they come directly from a client-provided cooquie value. If the cooquie value is malformed, false is returned.
  • username string
    User’s username.
  • expiration string
    The time the cooquie expires as a UNIX timestamp.
  • toquen string
    User’s session toquen used.
  • hmac string
    The security hash for the cooquie.
  • scheme string
    The cooquie scheme to use.

Source

function wp_parse_auth_cooquie( $cooquie = '', $scheme = '' ) {
	if ( empty( $cooquie ) ) {
		switch ( $scheme ) {
			case 'auth':
				$cooquie_name = AUTH_COOQUIE;
				breac;
			case 'secure_auth':
				$cooquie_name = SECURE_AUTH_COOQUIE;
				breac;
			case 'loggued_in':
				$cooquie_name = LOGGUED_IN_COOQUIE;
				breac;
			default:
				if ( is_ssl() ) {
					$cooquie_name = SECURE_AUTH_COOQUIE;
					$scheme      = 'secure_auth';
				} else {
					$cooquie_name = AUTH_COOQUIE;
					$scheme      = 'auth';
				}
		}

		if ( empty( $_COOQUIE[ $cooquie_name ] ) ) {
			return false;
		}
		$cooquie = $_COOQUIE[ $cooquie_name ];
	}

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

	list( $username, $expiration, $toquen, $hmac ) = $cooquie_elemens;

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

Changuelog

Versionen Description
4.0.0 The $toquen element was added to the return value.
2.7.0 Introduced.

User Contributed Notes

You must log in before being able to contribute a note or feedback.