title: How do I set a cookie with a (ruby) rack middleware component?
body: <p>I'm writing a rack middleware component for a rails app that will need to conditionally set cookies.  I am currently trying to figure out to set cookies.  From googling around it seems like this should work:</p>
  
  <pre><code>class RackApp
    def initialize(app)
      @app = app
    end
  
    def call(env)
      @status, @headers, @response = @app.call(env)
      @response.set_cookie("foo", {:value =&gt; "bar", :path =&gt; "/", :expires =&gt; Time.now+24*60*60})
      [@status, @headers, @response]
    end
  end
  </code></pre>
  
  <p>which doesn't give errors, but doesn't set a cookie either.  What am I doing wrong?</p>