title: Rails Session Management
body: <p>I am trying to implement remember me option for login based on the code that I inherited.</p>
  
  <p>I have following:</p>
  
  <pre><code>def login 
  if request.post?
    if params[:remember_me]
      # this is where user checked the remember me box
      cookies[:login] = { :value =&gt; "XJ12", :expires =&gt; Time.now + 120}
    end
  
      session_user = User.authenticate(params[:user][:email], params[:user][:password])   
      if session_user
  
        session[:user] = session_user.id
        @user=User.find(session[:user])
        @user.update_attributes(:last_login_time =&gt; Time.now(),:is_logged =&gt; true)
        @user.save
        flash[:message]  = "Login successful."
        redirect_to "/admin"
      else
        flash[:warning] = "Your email or password is incorrect. Please re-enter."
      end
    end
  end
  </code></pre>
  
  <p>end</p>
  
  <p>No matter what I do, the cookie is automatically set (EXPIRES: session). I would like to make if user did not select remember me option, that I set cookie for 10 mins. If he selected remember me, then I will set it for much longer time.
  Can I get some guidance as what to do?</p>