<p>I would like to access the Rails session secret programmatically (I am using it to generate a sign-on token).</p>

<p>Here's what I've come up with:</p>

<pre><code>ActionController::Base.session.first[:secret]
</code></pre>

<p>This returns the session secret. However, every time you call ActionController::Base.session it adds another entry to an array so you end up with something like this:</p>

<pre><code>[{:session_key=&gt;"_new_app_session", :secret=&gt;"totally-secret-you-guys"}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}, {}]
</code></pre>

<p>This strikes me as being no good.</p>

<p>Is there a better way to access the session secret?</p>

```
```
ActionController::Base.session_options_for(request,params[:action])[:secret]
```
```