0
好吧,所以我正在嘗試使用Ruby設置Cookie。我在Rack環境中。 response[name]=value
會在HTTP頭哈希機架中添加一個HTTP頭。我知道它的工作原理。設置Cookie
但設置cookie以下方法不起作用:
def set_cookie(opts={}) args = { :name => nil, :value => nil, :expires => Time.now+314, :path => '/', :domain => Cambium.uri #contains the IP address of the dev server this is running on }.merge(opts) raise ArgumentError, ":name and :value are mandatory" if args[:name].nil? or args[:value].nil? response['Set-Cookie']="#{args[:name]}=#{args[:value]}; expires=#{args[:expires].clone.gmtime.strftime("%a, %d-%b-%Y %H:%M:%S GMT")}; path=#{args[:path]}; domain=#{args[:domain]}" end
爲什麼不呢?我該如何解決它?謝謝。
您是通過機器的IP地址還是通過域名訪問您的網站? – zneak 2010-06-03 17:15:54
現在通過IP地址。 – 2010-06-03 20:45:28