1 common.inc backdrop_get_token($value = '')

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

Parameters

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

The generated token is based on the session ID of the current user. Normally, anonymous users do not have a session, so the generated token will be different on every page request. To generate a token for users without a session, manually start a session prior to calling this function.

Return value

string: A 43-character URL-safe token for validation,based on the user session ID, the global $hash_salt variable from settings.php, and the 'private_key' configuration variable.

File

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

Code

function backdrop_get_token($value = '') {
  return backdrop_hmac_base64($value, session_id() . backdrop_get_private_key() . backdrop_get_hash_salt());
}