3

I am using pyramid to create a web application. I am then using pyramid-beaker to interface beaker into pyramid's session management system.

Two values affect the duration of a user's session.

  1. The session cookie timeout
  2. The actual session's life time on either disk/memcache/rdbms/etc

I currently have to cookie defaulted (via the standard beaker config) to delete when the browser closes. I have the session data set to clear out after 2 hours. This works prefectly.

What I need to know is how to override the cookie's timeout and the session timeout to both be 30 days or some other arbirtrary value.

Andrew Martinez
  • 3,714
  • 3
  • 35
  • 38

2 Answers2

2

Changing the timeout isn't supported by beaker. If you are trying to make a session stick around that long, you should probably just put it into a separate cookie. A common use-case is the "remember me" checkbox on login. This helps you track who the user is, but generally the actual session shouldn't be sticking around that long and gets recreated.

Michael Merickel
  • 23,153
  • 3
  • 54
  • 70
  • Then why does Beaker take a timeout parameter? http://readthedocs.org/docs/beaker/en/v.1.6.1/modules/session.html – Jonatan Littke Mar 21 '12 at 14:07
  • 1
    Beaker handles creating cookies for you on first access to the SessionObject proxy in Pyramid. This makes the constructor parameters not configurable on a per-request basis with dissecting the internals of the SessionObject so that you can inject a manually created session into it or circumventing the SessionObject entirely. – Michael Merickel Mar 21 '12 at 15:08
  • OK, that makes sense. So strictly, your first sentence of your original reply isn't true, only in this context? Thanks :) (It does work for me in Pylons, though.) – Jonatan Littke Mar 22 '12 at 09:48
  • It'll work if you're manually creating `Session` or `CookieSession` objects yourself, but then you're responsible for ensuring things are persisted in your response object. Pretty sure if you're using the SessionMiddleware in Pylons you have the same problem. – Michael Merickel Mar 22 '12 at 14:56
1

I have a solution. Its old but works.

enomad
  • 1,053
  • 9
  • 16