title: How force that session is loaded?
body: <p>I'm working on an application that needs to use session id information. My session is stored in cookies. The problem I have is that my session is not immediately available to the controller when a user comes to the site for the first time. I think I may be missing something about how sessions are initialized in Rails. But I'm positve about the fact that the session is not loaded because this is the output of <code>session.inspect</code>:</p>
  
  <pre><code>#&lt;Rack::Session::Abstract::SessionHash:0x15cb970 not yet loaded&gt;
  </code></pre>
  
  <p>Here is how to reproduce the problem with <code>Rails 3.2.11</code> and <code>ruby 1.9.3</code>:</p>
  
  <p>Create a new application with a <code>test</code> controller:</p>
  
  <pre><code>rails new my_app
  cd my_app/
  rails g controller test
  rm app/assets/javascripts/test.js.coffee
  touch app/views/test/index.html.erb
  </code></pre>
  
  <p>Try to get the session id in that controller:</p>
  
  <pre><code>class TestController &lt; ApplicationController
    def index
      puts session[:session_id]
      puts session.inspect
    end
  end
  </code></pre>
  
  <p>Add the needed routes:</p>
  
  <pre><code>MyApp::Application.routes.draw do
    resources :test
  end
  </code></pre>
  
  <p>Then access the application and see what it does:</p>
  
  <pre><code>rails server
  </code></pre>
  
  <p>got to: <code>http://localhost:3000/test</code></p>
  
  <p>That is the output in the console:</p>
  
  <pre><code>#&lt;Rack::Session::Abstract::SessionHash:0x3fd10f50eea0 not yet loaded&gt;
  </code></pre>
  
  <p>Then again <code>http://localhost:3000/test</code> and this time we have a session:</p>
  
  <pre><code>400706c0b3d95a5a1e56521e455075ac
  {"session_id"=&gt;"400706c0b3d95a5a1e56521e455075ac", "_csrf_token"=&gt;"Euaign8Ptpj/o/8/ucBFMgxGtiH7goKxkxeGctumyGQ="}
  </code></pre>