Same name in other branches
  1. 7.x-1.x includes/admin.inc \advagg_admin_toggle_bypass_cookie()

Set or remove the AdvAggDisabled cookie.

Related topics

1 string reference to 'advagg_admin_toggle_bypass_cookie'
advagg_admin_operations_form in ./advagg.admin.inc
Form builder; Do advagg operations.

File

./advagg.admin.inc, line 1387

Code

function advagg_admin_toggle_bypass_cookie($form, &$form_state) {
    $cookie_name = 'AdvAggDisabled';
    $key = drupal_hmac_base64('advagg_cookie', drupal_get_private_key() . drupal_get_hash_salt() . variable_get('cron_key', 'drupal'));
    // If the cookie does exist then remove it.
    if (!empty($_COOKIE[$cookie_name]) && $_COOKIE[$cookie_name] == $key) {
        setcookie($cookie_name, '', -1, $GLOBALS['base_path'], '.' . $_SERVER['HTTP_HOST']);
        unset($_COOKIE[$cookie_name]);
        drupal_set_message(t('AdvAgg Bypass Cookie Removed.'));
    }
    else {
        // Cookie will last for 12 hours.
        setcookie($cookie_name, $key, REQUEST_TIME + $form_state['values']['timespan'], $GLOBALS['base_path'], '.' . $_SERVER['HTTP_HOST']);
        $_COOKIE[$cookie_name] = $key;
        drupal_set_message(t('AdvAgg Bypass Cookie Set for %time.', array(
            '%time' => format_interval($form_state['values']['timespan']),
        )));
    }
}