wp_validate_auth_cookie [ WordPress Function ]
| Parameters: |
|
| Returns: |
|
| Defined at: |
|
Validates authentication cookie.
The checks include making sure that the authentication cookie is set and pulling in the contents (if $cookie is not used).
Makes sure the cookie is not expired. Verifies the hash in cookie is what is should be and compares the two.
Source
<?php
function wp_validate_auth_cookie($cookie = '', $scheme = '') {
if ( ! $cookie_elements = wp_parse_auth_cookie($cookie, $scheme) ) {
do_action('auth_cookie_malformed', $cookie, $scheme);
return false;
}
extract($cookie_elements, EXTR_OVERWRITE);
$expired = $expiration;
// Allow a grace period for POST and AJAX requests
if ( defined('DOING_AJAX') || 'POST' == $_SERVER['REQUEST_METHOD'] )
$expired += 3600;
// Quick check to see if an honest cookie has expired
if ( $expired < time() ) {
do_action('auth_cookie_expired', $cookie_elements);
return false;
}
$user = get_user_by('login', $username);
if ( ! $user ) {
do_action('auth_cookie_bad_username', $cookie_elements);
return false;
}
$pass_frag = substr($user->user_pass, 8, 4);
$key = wp_hash($username . $pass_frag . '|' . $expiration, $scheme);
$hash = hash_hmac('md5', $username . '|' . $expiration, $key);
if ( $hmac != $hash ) {
do_action('auth_cookie_bad_hash', $cookie_elements);
return false;
}
if ( $expiration < time() ) // AJAX/POST grace period set above
$GLOBALS['login_grace_period'] = 1;
do_action('auth_cookie_valid', $cookie_elements, $user);
return $user->ID;
}
?>
Examples [ wp-snippets.com ]
Top Google zoekresultaten
- Function Reference/wp validate auth cookie « WordPress Codex
Description. Validates authentication cookie. The checks include making sure that the authentication cookie is set and pulling in the contents (if $cookie is not ...
codex.wordpress.org - wp_validate_auth_cookie (WordPress Function) - WPSeek.com
Oct 28, 2008 ... WordPress lookup for wp_validate_auth_cookie, a WordPress Function. wpseek. com is a WordPress-centric search tool for developers and ...
wpseek.com - [wp-hackers] Redirect and wp_validate_auth_cookie()
[wp-hackers] Redirect and wp_validate_auth_cookie(). Daniel Cortés daniel at kingubox.com. Tue Oct 28 01:44:48 GMT 2008. Previous message: [wp-hackers] ...
lists.automattic.com - wp_validate_auth_cookie
Function and Method Cross Reference. wp_validate_auth_cookie(). Defined at: / wp-includes/pluggable.php -> line 505. Referenced 5 times: ...
phpxref.ftwr.co.uk