# File lib/facets/more/cookie.rb, line 447
    def add(cookie)
      url = cookie.url
      name, value = cookie.name, cookie.value
      expires, domain, path = 
        cookie.expires, cookie.domain, cookie.path
      secure, domain_orig, path_orig = 
        cookie.secure?, cookie.domain_orig?, cookie.path_orig?
      discard, override = 
        cookie.discard?, cookie.override?

      domainname = url.host
      domain_orig, path_orig = domain, path
      use_security = override

      if !domainname
        cookie_error(NodotError.new(), override)
      end

      if domain

        # [DRAFT 12] s. 4.2.2 (does not apply in the case that
        # host name is the same as domain attribute for version 0
        # cookie)
        # I think that this rule has almost the same effect as the
        # tail match of [NETSCAPE].
        if domain !~ /^\./ && domainname != domain
          domain = '.'+domain
        end

        n = total_dot_num(domain)
        if n < 2
          cookie_error(SpecialError.new(), override)
        elsif @netscape_rule and n == 2
          ## [NETSCAPE] rule
          ok = SPECIAL_DOMAIN.select{|sdomain|
            sdomain == domain[-(sdomain.length)..-1]
          }
          if ok.empty?
            cookie_error(SpecialError.new(), override)
          end
        end

      end

      path ||= url.path.sub!(%r|/[^/]*|, '')
      domain ||= domainname
      cookie = find_cookie_info(domain, path, name)

      if !cookie
        cookie = Web::Cookie.new()
        cookie.use = true
        @cookies << cookie
      end

      cookie.url = url
      cookie.name = name
      cookie.value = value
      cookie.expires = expires
      cookie.domain = domain
      cookie.path = path

      ## for flag
      cookie.secure = secure
      cookie.domain_orig = domain_orig
      cookie.path_orig = path_orig
      if discard || cookie.expires == nil
        cookie.discard = true
      else
        cookie.discard = false
        @is_saved = false
      end

      check_expired_cookies()
      return false
    end