A HitchHackers guide through WordPress


Home | Pages | Archives


wp_verify_nonce

February 12, 2011 5:54 am

Definition:
function wp_verify_nonce($nonce, $action = -1) {}

Verify that correct nonce was used with time limit.
The user is given an amount of time to use the token, so therefore, since the UID and $action remain the same, the independent variable is the time.

Parameters

Return values

returns:Whether the nonce check passed or failed.

Source code

function wp_verify_nonce($nonce, $action = -1) {

	$user = wp_get_current_user();

	$uid = (int) $user->ID;



	$i = wp_nonce_tick();



	// Nonce generated 0-12 hours ago

	if ( substr(wp_hash($i . $action . $uid, 'nonce'), -12, 10) == $nonce )

		return 1;

	// Nonce generated 12-24 hours ago

	if ( substr(wp_hash(($i - 1) . $action . $uid, 'nonce'), -12, 10) == $nonce )

		return 2;

	// Invalid nonce

	return false;

}

4259

Rate this:

Posted by Thorsten

Categories: /wp-includes/pluggable.php, Documentation, Files, Functions, Functions by letter w

Tags: , ,

Leave a Reply



Mobile Site | Full Site


Get a free blog at WordPress.com Theme: WordPress Mobile Edition by Alex King.