You are here

function esi_init in ESI: Edge Side Includes 6.2

Same name and namespace in other branches
  1. 7.3 esi.module \esi_init()

Implementation of hook_init().

File

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

Code

function esi_init() {

  // Set RSESS/USESS cookie if not set and user is logged in.
  global $user;
  if (!empty($user->uid) && (empty($_COOKIE['R' . session_name()]) || empty($_COOKIE['U' . session_name()]))) {
    $edit = '';
    esi_user('login', $edit, $user);
  }

  // If ESI or AJAX Fallback is disabled then do not add in the esi.js file.
  if (!variable_get('esi_mode', ESI_MODE) || !variable_get('esi_ajax_fallback', ESI_AJAX_FALLBACK)) {
    return;
  }
  drupal_add_js(drupal_get_path('module', 'esi') . '/esi.js');
}