title: How to set cookie so it appears back on form?
body: <p>I have a field called <code>params[:search_loc]</code> that's for a public user where they can put in there address and get results near there. I'm trying to save it in a cookie so when a public user leaves a page they can come back and have the same address until they change it. Here is the view and the controller. This is what I tried.</p>
  
  <p><strong>Controller</strong></p>
  
  <pre><code>def index
    @dad = Dad.find(params[:dad_id])
    cookies[:search_loc] = params[:search_loc]
    if user_signed_in?
     near = Mom.near(@user_location, 500, select: "kids.*")
    elsif cookies[:search_loc].present?
     near = Mom.near(cookies[:search_loc], 500, select: "kids.*")
    elsif params[:search_loc].present?
     near = Mom.near(params[:search_loc], 500, select: "kids.*")
    end
  end
  </code></pre>
  
  <p><strong>View</strong></p>
  
  <pre><code>&lt;% if params[:search_loc].blank? %&gt;
     &lt;%= form_tag dad_kids_path(@dad), method: :get do %&gt;
        &lt;%= text_field_tag :search_loc, params[:search_loc] %&gt;
           &lt;%= button_tag(type: 'submit') do %&gt;
             Save
           &lt;% end %&gt;
        &lt;% end %&gt;
     &lt;% end %&gt;
  &lt;% end %&gt;
  </code></pre>
  
  <p>Right now it doesn't set the cookie for the address but it is saved in the browser. How can I get it to show in the <code>search_loc</code> field after I leave to another page?</p>