title: Rails 3, add id param to cookie array
body: <p>I have the following code...</p>
  
  <p>view</p>
  
  <pre><code>&lt;% @products.each do |product| %&gt;
    &lt;tr&gt;
     ...
      &lt;td&gt;&lt;%= link_to "Add to Cart", add_to_cart_product_path(product), :method =&gt; :put %&gt;&lt;/td&gt;
    &lt;/tr&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>controller</p>
  
  <pre><code>def add_to_cart
      if cookies[:products].blank?
        cookies[:products] = params[:id]
      else
        cookies[:products] = cookies[:products] &lt;&lt; params[:id]
      end
      redirect_to products_url
    end
  end
  </code></pre>
  
  <p>I'm trying to build a super simple simulation of a shopping cart. I have products, and I want to add the product_id to my products cookie if the user clicks 'add to cart'. The issue I'm having is I only get a single id in the cookie at a time. In fact the cookie on seems to get written to the first time I click 'add to cart' for a product. After that, nothing is written.</p>