How do I use a cookie session with pyramid & beaker to properly store a session_id?
<p>I am using the pyramid framework with beaker as a back-end for session management, and I want to store a session_id within a signed cookie. The session-id is associated with a real user_id, and the association mappings will be stored in something like redis. Can I simply use the configuration below to achieve this? The documentation doesn't provide a full implementation and only shows an example using an unsecure session factory.  </p>

<p>Here is my configuration file, redacted to session details:</p>

<pre><code>session.type = cookie
session.data_dir = %(here)s/data/sessions/data
session.lock_dir = %(here)s/data/sessions/lock
session.key = session_key
session.secret = as98&amp;$Hh94
session.cookie_on_exception = true
</code></pre>

<p>Here is my <code>__init__.py</code>:</p>

<pre><code>config = Configurator(settings=settings)
config.include('pyramid_jinja2')
config.include('pyramid_beaker')
config.include('.models')
config.include('.routes')
config.include('polatick.models')
config.scan()
return config.make_wsgi_app()
</code></pre>

<p>Do I simply use the forget and remember functions in pyramid to do this properly?</p>

<p>I was thinking of the process going something along the lines of something simple like this:</p>

<pre><code>if user_authenticates():
   session_id = create_session_id()
   redis.put_entry(session_id, user_id)
   request.session['session_id'] = session_id
   headers = remember(request, login)
   return HTTPFound('/', headers=headers)
</code></pre>

<p>I've been following this documentation:<br>
<a href="http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pylons/sessions.html" rel="nofollow noreferrer">http://docs.pylonsproject.org/projects/pyramid_cookbook/en/latest/pylons/sessions.html</a></p>