You are here

function esi_boot in ESI: Edge Side Includes 7.3

Same name and namespace in other branches
  1. 6.2 esi.module \esi_boot()

Implements hook_boot().

File

./esi.module, line 144
Adds support for ESI (Edge-Side-Include) integration, allowing components\ to be delivered by ESI, with support for per-component cache times.

Code

function esi_boot() {

  // Set context cookies if not set and user is logged in.
  global $user;

  // ESI will *always* set a cookie in order to determine if cookies need to be
  // resent. That cookie's name will be:
  // ESI_:                    if the "Harden cookie key" setting is disabled.
  // ESI_{_32-char-MD5-hash}: if the "Harden cookie key" setting is enabled.
  $sessify = variable_get('esi_harden_cookie_key', TRUE);
  $session_name = $sessify ? '_' . session_name() : '';

  // Expect *at least* an "ESI_{$session_name}" cookie.
  // Use this as the basis for refreshing context cookies.
  if ($user->uid && empty($_COOKIE["ESI_{$session_name}"])) {

    // No ESI cookie? REFRESH ALL THE ESI COOKIES!
    esi__set_user_contexts($user);
  }
}