1 common.inc backdrop_valid_token($token, $value = '', $skip_anonymous = FALSE)

Validates a token based on $value, the user session, and the private key.

Parameters

string $token: The token to be validated.

string $value: An additional value to base the token on.

bool $skip_anonymous: Set to true to skip token validation for anonymous users.

Return value

bool: True for a valid token, false for an invalid token. When $skip_anonymous is true, the return value will always be true for anonymous users.

File

core/includes/common.inc, line 6315
Common functions that many Backdrop modules will need to reference.

Code

function backdrop_valid_token($token, $value = '', $skip_anonymous = FALSE) {
  global $user;
  return (($skip_anonymous && $user->uid == 0) || ($token === backdrop_get_token($value)));
}