function domain(url){
  var cookie = exports.cookie;
  var levels = exports.levels(url);

  // Lookup the real top level one.
  for (var i = 0; i < levels.length; ++i) {
    var cname = '__tld__';
    var domain = levels[i];
    var opts = { domain: '.' + domain };

    cookie(cname, 1, opts);
    if (cookie(cname)) {
      cookie(cname, null, opts);
      return domain
    }
  }

  return '';
}
Get the top domain.

The function constructs the levels of domain
and attempts to set a global cookie on each one
when it succeeds it returns the top level domain.

The method returns an empty string when the hostname
is an ip or `localhost`.

Example levels:

     domain.levels('http://www.google.co.uk');
     // => ["co.uk", "google.co.uk", "www.google.co.uk"]

Example:

     domain('http://localhost:3000/baz');
     // => ''
     domain('http://dev:3000/baz');
     // => ''
     domain('http://127.0.0.1:3000/baz');
     // => ''
     domain('http://segment.io/baz');
     // => 'segment.io'

@param {String} url
@return {String}
@api public