Removing hard-coded cookies from ExpressionEngine

A client is using ExpressionEngine 2 as just a CMS and not using its membership features, and we're doing everything we can to improve performance, both back-end and front-end.

On the front-end side, the cookie setting takes up some of the precious bytes that get transferred before the browser can start downloading assets.

I have turned off everything I can turn off that adds cookies to ExpressionEngine's output, but there were still two cookies hard-coded into the output even for logged-off users: exp_tracker and exp_last_activity.

The code that does this is in expressionengine/libraries/Session.php:
  • $this->EE->functions->set_cookie('tracker', serialize($tracker), '0');
  • $this->EE->functions->set_cookie('last_activity', $this->EE->localize->now, $expire);
This was a bit tricky to find, and I didn't see answers on Google, so there it is for posterity.

Note that EllisLab staff says making this change "can affect your ability to upgrade, and your ability to receive support." They also point out that you would need to re-apply such changes after an upgrade.