You are here

function esi_get_user_hash in ESI: Edge Side Includes 6.2

Get the hash for a user.

Parameters

int $uid: User ID.

2 calls to esi_get_user_hash()
esi_user in ./esi.module
Implementation of hook_user(). For maximum cache-efficiency, the proxy must be able to identify the roles held by a user. A cookie is used which provides a consistent hash for all users who share the same roles. For security, the hash uses a random…
theme_esi_tag in ./esi.theme.inc
Create the ESI-tag for a particular block.

File

./esi.inc, line 81
Helper functions for the ESI module.

Code

function esi_get_user_hash($uid = NULL) {
  static $users = array();

  // Get current user if uid was not passed in.
  if (empty($uid)) {
    global $user;
    $uid = isset($user->uid) ? $user->uid : 0;
  }

  // Create a hash of the user.
  if (!isset($users[$uid])) {
    $seed = _esi__get_seed_key();
    $users[$uid] = md5($seed . md5($uid));

    // Invloke hook_esi_user_hash().
    drupal_alter('esi_user_hash', $users[$uid], $uid, $seed);
  }
  return $users[$uid];
}