title: How to store simple user preferences in the session
body: <p>When someone visits <a href="http://www.bettermetronorth.com/" rel="nofollow noreferrer">my train schedule site</a>, he enters a "from station", a "to station", and then submits the form to get the schedule.</p>
  
  <p>I want the site to remember the user's last choice of from / to station when he next visits the site. Here's my current strategy:</p>
  
  <p>In my <code>index</code> action (the action corresponding to the root URL):</p>
  
  <pre><code>def index  
    to_station = "Grand Central Terminal"
    from_station = ""
  
    if session[:from_station]
      from_station = session[:from_station]
    end
    if session[:to_station]
      to_station = session[:to_station]
    end
  
    @schedule = Schedule.new(:to_station =&gt; to_station, :from_station =&gt; from_station)
  end
  </code></pre>
  
  <p>In my <code>show</code> action (the action that shows the actual train schedule):</p>
  
  <pre><code>def show
    @schedule = Schedule.new(params[:schedule])
  
    if @schedule.trains
      session[:from_station] = @schedule.from_station
      session[:to_station] = @schedule.to_station
      render :partial =&gt; 'table', :locals =&gt; { :schedule =&gt; @schedule }
    else
      render :partial =&gt; 'error', :locals =&gt; { :schedule =&gt; @schedule }
    end
  end
  </code></pre>
  
  <p>And in my <code>ApplicationController</code>:</p>
  
  <pre><code>  session :session_expires =&gt; 1.year.from_now
  </code></pre>
  
  <p>Is this the right approach? In particular, is <code>session :session_expires =&gt; 1.year.from_now</code> the "right" way to make the session (and by extension the user's choice of stations) last for a "long time"?</p>