title: Migrating sessions from cookie_store to Redis in Rails 3
body: <p>I need to switch the session store in my Rails 3 app from <em>cookie_store</em> to <a href="https://github.com/roidrage/redis-session-store" rel="nofollow">redis-session-store</a>. There are many reasons for this (security, SSO with other Rails and non-Rails apps). Are there any best practices on how to do it <strong>without loosing all current sessions</strong>?</p>
  
  <p>What i could imagine is a two steps approach:</p>
  
  <ol>
  <li>Collect all user sessions for N days and store them in the DB or in Redis (update if already stored).</li>
  <li>Use stored user sessions to create entries in Redis.</li>
  </ol>
  
  <p>Alternatively, on the fly migration would also be possible. Means read cookies, use secret key to decrypt the session data and store it as a new session in Redis.</p>