title: Session data not being saved in Sinatra simple authentication
body: <p>I created a simple authentication for Sinatra, however the session object seems to be cleaning up ALL custom keys. For example, when user logs in:</p>
  
  <pre><code>session[:user_id] = current_user.id
  </code></pre>
  
  <p>This is effectively stored in the session object for the current request. When a new request occurs the session[:user_id] is not there anymore. Session is active, cookies are enabled. I tried everything I can't figure out what it wrong (here is the all the relevant code: <a href="https://gist.github.com/ksiomelo/7656296" rel="nofollow">https://gist.github.com/ksiomelo/7656296</a>).</p>
  
  <p>application:</p>
  
  <pre><code> use Rack::Session::Cookie , :secret =&gt; "82e042cd6fde2bf1764f777236db799e"
  
   enable :sessions # for flash messages
  </code></pre>
  
  <p>helpers:</p>
  
  <pre><code> def require_auth
    unless session[:user_id]
      flash[:error] = "You need to be logged in."
      redirect to("/login")
    end
  end
  
  def current_user
    @current_user ||= User.find_by_id(session[:user_id]) if session[:user_id]
  end
  </code></pre>
  
  <p>signin:</p>
  
  <pre><code>   authorized_user = User.authenticate(params[:email],params[:password])
        if authorized_user
          # update session / redirect
          session[:user_id] = authorized_user.mongo_id.to_s 
          session.options[:expire_after] = 2592000 unless params[:remember].nil? # 30 days
  
          # redirect to the wizard
          flash[:info] = "Welcome back #{authorized_user.first_name}"
          redirect to("/home")
  </code></pre>