You are here

function boost_set_cookie in Boost 6

Same name and namespace in other branches
  1. 7 boost.module \boost_set_cookie()

Sets a special cookie preventing authenticated users getting served pages from the static page cache.

Parameters

$uid: User ID Number

$expires: Expiration time

2 calls to boost_set_cookie()
boost_init in ./boost.module
Implementation of hook_init(). Performs page setup tasks if page not cached.
boost_user in ./boost.module
Implementation of hook_user(). Acts on user account actions.

File

./boost.module, line 4632
Provides static file caching for Drupal text output. Pages, Feeds, ect...

Code

function boost_set_cookie($uid, $expires = NULL) {
  if (!$expires) {

    // Let the old way still work, in case user object was passed
    $uid = is_object($uid) ? $uid->uid : $uid;
    $expires = ini_get('session.cookie_lifetime');
    $expires = !empty($expires) && is_numeric($expires) ? BOOST_TIME + (int) $expires : 0;
    setcookie(BOOST_COOKIE, strval($uid), $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
  }
  else {
    setcookie(BOOST_COOKIE, '0', $expires, ini_get('session.cookie_path'), ini_get('session.cookie_domain'), ini_get('session.cookie_secure') == '1');
  }
  $GLOBALS['_boost_cache_this'] = FALSE;
}