[mod_python] Using session management?

Steve Bergman steve at rueb.com
Thu Sep 15 20:22:49 EDT 2005

Is there good documentation somewhere on using the Session module, 
preferably with examples?  From the mod_python manual, I've gotten this far:

from mod_python import Session

def main(req):
    sess = Session.Session(req)
    if sess.is_new():
        s = '<html>This is a new session.</html>'
        sess.myVar2 = "I am a session variable."
        return s
        s='<html>This is an old session.  myVar2 = ' + sess.myVar2 + 
        s+= sess.myVar2
        return s

This works in that the first time, I get "This is a new session" and it 
does not complain about setting sess.myVar2.

But on the second load, it complains that dbmSesion does not have an 
attribute myVar2.

When you save the session, what all gets saved?

Steve Bergman

More information about the Mod_python mailing list