return new WP_Error( 'invalid_created_at',
__( 'Invalid cookie format.'
) );
} /** This filter is documented in wp-includes/class-wp-recovery-mode-cookie-service.php */
$length =
apply_filters( 'recovery_mode_cookie_length', WEEK_IN_SECONDS
);
if ( time() >
$created_at +
$length ) { return new WP_Error( 'expired',
__( 'Cookie expired.'
) );
} $to_sign =
sprintf( 'recovery_mode|%s|%s',
$created_at,
$random );
$hashed =
$this->
recovery_mode_hash( $to_sign );
if ( !
hash_equals( $signature,
$hashed ) ) { return new WP_Error( 'signature_mismatch',
__( 'Invalid cookie.'
) );
} return true;
} /**
* Gets the session identifier from the cookie.
*
* The cookie should be validated before calling this API.
*
* @since 5.2.0
*
* @param string $cookie Optionally specify the cookie string.
* If omitted, it will be retrieved from the super global.
* @return string|WP_Error Session ID on success, or error object on failure.
*/