title: troubleshooting session persistent issues in rails 3.1
body: <p>i need some pointers on how to troubleshoot session problems - right now my session isn't persisting and I am working on an app where I couldn't get a straight communication with the previous programmers.</p>
  
  <p>I found out 2 things.</p>
  
  <p>Using cookies as session store - the session never persist. Eg,</p>
  
  <pre><code>def action1
    session[:counter] = 1
    redirect_to action: action2
  end
  
  def action2
    # session[:counter] -&gt; this is now nil
  end
  </code></pre>
  
  <p>Then i switched my session store to using database, and it will persist on the next action, BUT after i refresh the page, the session is gone and i noticed a new session was created.</p>
  
  <p>There are multiple subdomains happening in the code, but - on my examples, there is no subdomain or we can say the url stays the same all the time.</p>
  
  <p>EDIT:</p>
  
  <p>this could be a clue, so i switched over to active record store, I can see that rails is creating a new session for instance. if i go to /page on browser tab1, go to /page again but on a different tab, rails will create a new session. this goes the same if i refresh the page.</p>