def load_cookies(file)
      now = ::Time.now

      io = case file
      when String
        open(file)
      else
        file
      end

      io.each_line do |line|
        line.chomp!
        line.gsub!(/#.+/, '')
        fields = line.split("\t")

        next if fields.length != 7

        name, value, domain, for_domain, path, secure, version = fields[5], fields[6], 
          fields[0], (fields[1] == "TRUE"), fields[2], (fields[3] == "TRUE"), 0

        expires_seconds = fields[4].to_i
        expires = (expires_seconds == 0) ? nil : ::Time.at(expires_seconds)
        next if expires and (expires < now)

        cookies.add(name, value, domain: domain, path: path, expires: expires, secure: secure)
      end

      io.close if String === file

      self
    end
def load_cookies(file)
      now = ::Time.now

      io = case file
      when String
        open(file)
      else
        file
      end

      io.each_line do |line|
        line.chomp!
        line.gsub!(/#.+/, '')
        fields = line.split("\t")

        next if fields.length != 7

        name, value, domain, for_domain, path, secure, version = fields[5], fields[6], 
          fields[0], (fields[1] == "TRUE"), fields[2], (fields[3] == "TRUE"), 0

        expires_seconds = fields[4].to_i
        expires = (expires_seconds == 0) ? nil : ::Time.at(expires_seconds)
        next if expires and (expires < now)

        cookies.add(name, value, domain: domain, path: path, expires: expires, secure: secure)
      end

      io.close if String === file

      self
    end
Read cookies from Mozilla cookies.txt-style IO stream

 @param file [IO,String]