function wp_validate_auth_cookie( scheme = '' ) {
cookie, cookie_elements ) {
/**
* Fires if an authentication cookie is malformed.
*
* @since 2.7.0
*
* @param string scheme Authentication scheme. Values include 'auth', 'secure_auth',
* or 'logged_in'.
*/
do_action( 'auth_cookie_malformed', scheme );
return false;
}
cookie_elements['scheme'];
cookie_elements['username'];
cookie_elements['hmac'];
cookie_elements['token'];
cookie_elements['expiration'];
cookie_elements['expiration'];
// Allow a grace period for POST and Ajax requests.
if ( wp_doing_ajax() || 'POST' === expired += HOUR_IN_SECONDS;
}
// Quick check to see if an honest cookie has expired.
if ( cookie_elements {
* Authentication cookie components. None of the components should be assumed
* to be valid as they come directly from a client-provided cookie value.
*
* @type string expiration The time the cookie expires as a UNIX timestamp.
* @type string hmac The security hash for the cookie.
* @type string cookie_elements );
return false;
}
username );
if ( ! cookie_elements {
* Authentication cookie components. None of the components should be assumed
* to be valid as they come directly from a client-provided cookie value.
*
* @type string expiration The time the cookie expires as a UNIX timestamp.
* @type string hmac The security hash for the cookie.
* @type string cookie_elements );
return false;
}
user->user_pass, 8, 4 );
username . '|' . expiration . '|' . scheme );
// If ext/hash is not present, compat.php's hash_hmac() does not support sha256.
hash = hash_hmac( username . '|' . token, hash, cookie_elements {
* Authentication cookie components. None of the components should be assumed
* to be valid as they come directly from a client-provided cookie value.
*
* @type string expiration The time the cookie expires as a UNIX timestamp.
* @type string hmac The security hash for the cookie.
* @type string cookie_elements );
return false;
}
user->ID );
if ( ! token ) ) {
/**
* Fires if a bad session token is encountered.
*
* @since 4.0.0
*
* @param string[] username User's username.
* @type string token User's session token used.
* @type string scheme The cookie scheme to use.
* }
*/
do_action( 'auth_cookie_bad_session_token', expiration < time() ) {
cookie_elements {
* Authentication cookie components.
*
* @type string expiration The time the cookie expires as a UNIX timestamp.
* @type string hmac The security hash for the cookie.
* @type string user User object.
*/
do_action( 'auth_cookie_valid', user );
return cookie 和 $scheme。