Drupal 7 has a cookie called has_js. drupal.js sets this cookie, and it is used by the Batch API and the authorize.php script.

There is a rather old issue about this cookie, backport "$_COOKIE['has_js'] must die" patch to 7.x, but this cookie still remains in drupal-7.x.

Are there any acceptable uses for this cookie, outside these two cases in core?

  • I do not consider this a duplicate of drupal.stackexchange.com/questions/77967/…. I encountered a module that uses this cookie, but in some instances its use causes bugs. I am trying to determine the proper course of action for my patch.
    – mpdonadio
    Apr 10, 2014 at 19:07

1 Answer 1


I don't think so, for many separate reasons.

  1. Given the comment made to 8.x change records Removed has_js cookie:

    Only Batch API used it as a workaround. A clean solution has been reached avoiding the need for the cookie.

    I would extrapolate that any solution that uses it should be considered unclean.

  2. There is no page for it on api.drupal.org so it appears it wasn't designed to be used outside and it's not guaranteed to stay unchanged. It's a common in IT to assume one uses undocumented features at his own risk.

  3. It can be unset if JavaScript is on, but Cookies are off, so it cannot have a clear meaning.

  4. It can be unset if some module will successfully try to make site EU Cookie Law compliant (and user didn't agreed yet)

  5. If you read it from PHP, it will be unset if your page is first one loaded after "open in private window" or "clear cookies" click, no matter what are client's JS and Cookie settings.

Reasons in no particular order.

  • #5 is the exact reason I am asking this. I spent the better part of this afternoon boiling down my problem to the cookie in this situation.
    – mpdonadio
    Apr 10, 2014 at 22:33
  • @MPD I can't imagine how this could be avoided, when using cookies. I would try to go for a page with JavaScript redirect to JavaScript-enabled implementation, and link + http refresh (with longer delay) to trigger non-JS implementation. But it all depends on what you are trying to implement.
    – Mołot
    Apr 11, 2014 at 6:30

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.