function boost_cookie_handler in Boost 7
Logic for the setting and removal of the boost cookie.
1 string reference to 'boost_cookie_handler'
- boost_init in ./
boost.module - Implements hook_init().
File
- ./
boost.module, line 785 - Caches generated output as a static file to be served directly from the webserver.
Code
function boost_cookie_handler() {
global $user;
// Check if Drupal is started from index.php - could cause problems with other
// contrib modules like ad module.
if (strpos($_SERVER['SCRIPT_FILENAME'], 'index.php') === FALSE) {
return;
}
$uid = isset($user->uid) ? $user->uid : 0;
// Remove Boost cookie at logout if it still exists.
if (isset($_COOKIE[BOOST_COOKIE]) && $uid == 0) {
boost_set_cookie($uid, REQUEST_TIME - 86400);
}
elseif ((!isset($_COOKIE[BOOST_COOKIE]) || $_COOKIE[BOOST_COOKIE] == '-1') && $uid != 0) {
boost_set_cookie($uid);
}
elseif (isset($_COOKIE[BOOST_COOKIE]) && $_COOKIE[BOOST_COOKIE] == '-1' && ($_SERVER['REQUEST_METHOD'] == 'GET' || $_SERVER['REQUEST_METHOD'] == 'HEAD')) {
boost_set_cookie($uid, REQUEST_TIME - 86400);
}
// Issue #1242416: Set a nocache cookie on a POST, remove it immediately after
// (on GET) Only necessary for anon users, since we already do not cache for
// logged in users. Also note that if we are processing a GET, it means that
// we have already been through the htaccess rules, so the cookie has done
// its job and can be removed.
if ($uid == 0 && $_SERVER['REQUEST_METHOD'] != 'GET' && $_SERVER['REQUEST_METHOD'] != 'HEAD') {
boost_set_cookie(-1);
}
}