var x = "" + self.location;
i = x.indexOf("?");

if (i > 0) {
  x = x.substr(i + 1, x.length - i - 1);

  var expDays = 30;
  var exp = new Date();
  exp.setTime(exp.getTime() + (expDays*24*60*60*1000));

  document.cookie = "refid="
                  + escape(x)
                  + ";expires="
                  + exp.toGMTString()
                  + ';domain=host-web-site.com;path=/';
}