set cookie(s)


  
      function set_cookies()
      {
          if (preg_match_all("#set-cookie:([^\r\n]*)#i", this->response_headers, matches))
          {
              foreach (matches[1] as match)
              {
                  preg_match('#^\s*([^=;,\s]*)=?([^;,\s]*)#', match, cookie)  ? list(, name, value) = cookie : null;
                  preg_match('#;\s*expires\s*=([^;]*)#i', match, cookie)      ? list(, expires)      = cookie : null;
                  preg_match('#;\s*path\s*=\s*([^;,\s]*)#i', match, cookie)   ? list(, path)         = cookie : null;
                  preg_match('#;\s*domain\s*=\s*([^;,\s]*)#i', match, cookie) ? list(, domain)       = cookie : null;
                  preg_match('#;\s*(secure\b)#i', match, cookie)              ? list(, secure)       = cookie : null;
  
                  expires = isset(expires) ? strtotime(expires) : 0;
                  path    = isset(path)    ? path : this->url_segments['dir'];
                  domain  = isset(domain)  ? domain : this->url_segments['host'];
                  domain  = rtrim(domain, '.');
                  
                  if (!preg_match("#domain#i", this->url_segments['host']))
                  {
                      continue;
                  }
                  if (preg_match('#\.(com|edu|net|org|gov|mil|int|aero|biz|coop|info|museum|name|pro)#i', domain))
                  {
                      if (substr_count(domain, '.') < 2)
                      {
                          continue;
                      }
                  }
                  else if (substr_count(domain, '.') < 3) 
                  {
                      continue;
                  }
                  setcookie(urlencode("PHProxy;name;domain;path"), value, expires, '', _SERVER['HTTP_HOST']);
              }
          }
      }