Comment 7 for bug 529252

Revision history for this message
Kevin Miller (kemiller) wrote :

To allow Varnish to remove the has_js cookie for logged-in users, therefore allowing stuff like ctools and batchapi to work, we just wrote the following into a 'tweaks' module. This puts the has_js javascript into the header, but then removes any has_js cookies on logout.

<code>
/**
* Add the has_js cookie to the user's JS entry
*/
function site_tweaks_init() {
 global $user;
 if($user->uid > 0) {
  drupal_add_js('document.cookie = "has_js=1; path=/";', 'inline');
 }
}

/**
* Adds a 'has_js' cookie for only logged-in users
*/
function site_tweaks_user($op, &$edit, $account) {
 if($op == 'logout') {
  setcookie('has_js', '', time() - 3600);
 }
}
</code>