[mod_python] Session management

Peter Sanchez petersanchez at gmail.com
Wed Nov 2 11:02:16 EST 2005

Remember to .save() the session, then upon return, it won't be is_new()..

sess = Session.Session(req)
if sess.is_new():
  sess['foo'] = 'bar'
  print 'Hello %s' % sess['foo']

Hope this helps.


On 11/2/05, Ognen Duzlevski <oduzlevski at intechjanus.com> wrote:
> Hi all,
> I read this paragraph from the BaseSession docs:
> "id is an optional session id; if provided, such a session must already
> exist, otherwise it is ignored and a new session with a new sid is
> created. If sid is not provided, the object will attempt to look at
> cookies for session id. If a sid is found in cookies, but it is not
> previously known or the session has expired, then a new sid is created.
> Whether a session is ``new'' can be determined by calling the is_new()
> method."
> Does this imply that I can do the following:
> create a Session() object and it will somehow decide where to go (say
> dbm or memory)
> on the next visit to the same page I should be able to do ms =
> Session.Session(req) and ms.is_new() will tell me that this session is
> not new because it was looked up (through the cookie pysid I am
> assuming) and found in the persistant storage (like for dbm or memory,
> either way)?
> Thanks,
> Ognen
> _______________________________________________
> Mod_python mailing list
> Mod_python at modpython.org
> http://mailman.modpython.org/mailman/listinfo/mod_python

More information about the Mod_python mailing list