title: Rails sessions stored in database
body: <p>I have a page that shows a list of events. When the event is clicked it takes you to a login page and it keeps the session id along with the page. When I go to the next page it always sends the last session variable. </p>
  
  <pre><code>&lt;% @events.each do |e| %&gt;
  &lt;%= link_to e.event_name, sessions_new_path %&gt;
  &lt;%= e.event_start %&gt; - &lt;%= e.event_stop %&gt;
  &lt;% session[:event_id] = e.id %&gt;
  &lt;%= session[:event_id] %&gt;
  &lt;br&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>This shows the session[:event_id] is there and it is storing in the variable but when I click on the link it will send the last session[:event_id] of the loop. Any ideas would be helpful. I am looking at option of either passing the variable to the next page or storing it into a database cell, but not sure on how sessions are stored in databases.</p>