Ruby CGI 设置 Cookie 和其他 HTTP 头

清华大佬耗费三个月吐血整理的几百G的资源,免费分享!....>>>

#!/usr/bin/ruby

require "cgi"
cgi = CGI.new("html3")

cookie = cgi.cookies['yourCookie']
cookie = CGI::Cookie.new('yourCookie', 'hits=0',
                         "last=#{Time.now}") if cookie.empty?

hits = cookie.value[0].split('=')[1]
last = cookie.value[1].split('=')[1]

cookie.value[0] = "hits=#{hits.succ}"
cookie.value[1] = "last=#{Time.now}"