title: Rails session variable (shopping cart)
body: <p>I'm trying to save the items the customer can add to my shopping cart in a session variable.
  Below is my index method in the cart controller. The ID of the item is saved in @idtemp. Next I create a new array session[:content]. Then I find the item with the ID saved in @idtemp and return it as an array, which is used in the view to display the table. The problem is, everytime an item is added and the index function is called, session[:contenc] is set to [], deleting the cart, which means that a newly added item overwrites the last one.
  Now I want this fixed so that a newly added item is added to the array without overwriting the last one,  but I dont know how. I tried to initialize the session variable outside of index but that didnt work somehow. I know this is piss easy but I am pretty exhausted and cant figure it out.</p>
  
  <p>def index</p>
  
  <pre><code>  @idtemp = session[:cart]
  
    session[:content] = []
    session[:content] = session[:content] &lt;&lt; (Artikel.find([@idtemp]))
  
    @cart = session[:content]
  </code></pre>
  
  <p>end</p>
  
  <p>-----view: </p>
  
  <p>
    &lt;% @cart.each do |id,quantity| %>
        ...
        ...</p>