You are here

function authcache_user_key in Authenticated User Page Caching (Authcache) 7.2

Calculate key for logged in user from key-properties record.

Parameters

array $properties: Structure with key-value pairs as returned by authcache_key_properties()

bool $superuser: Whether the key is calculated for the superuser. If set to TRUE the properties data is hashed twice in order to make the key unique.

Related topics

2 calls to authcache_user_key()
authcache_enum_user_keys in modules/authcache_enum/authcache_enum.module
Enumerate every possible authcache key for authenticated users.
authcache_key in ./authcache.module
Generate and return the authcache key for the given account.
2 string references to 'authcache_user_key'
AuthcacheEnumKeysTestCase::testCustomAuthenticatedKeys in modules/authcache_enum/lib/Drupal/authcache_enum/Tests/AuthcacheEnumKeysTestCase.php
Test authenticated key customization.
AuthcacheEnumKeysTestCase::testDeprecatedCustomAuthenticatedKeys in modules/authcache_enum/lib/Drupal/authcache_enum/Tests/AuthcacheEnumKeysTestCase.php
Test deprecated authenticated key customization.

File

./authcache.module, line 629
Authenticated User Page Caching (and anonymous users, too!)

Code

function authcache_user_key($properties, $superuser = FALSE) {
  ksort($properties);
  $data = serialize($properties);
  $hmac = hash_hmac('sha1', $data, drupal_get_private_key(), FALSE);

  // Make sure superuser has its own key not shared with anyone else (though
  // it would be better if superuser would'nt be allowed to use the cache in
  // the first place).
  if ($superuser) {
    $hmac = hash_hmac('sha1', $hmac . $data, drupal_get_private_key(), FALSE);
  }
  $abbrev = variable_get('authcache_key_abbrev', 7);
  return $abbrev ? substr($hmac, 0, $abbrev) : $hmac;
}