[mod_python] Session management

Ognen Duzlevski oduzlevski at intechjanus.com
Wed Nov 2 11:09:27 EST 2005


Jim Gallacher wrote:

> Ognen Duzlevski 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)?
>
>
> That's pretty much it. The important thing is that you *must* call 
> ms.save() to save your session data to the persistent store. Otherwise 
> each visit to the same page will generate a new sid.
>
> The default store is platform dependant depending on which apache-mpm 
> you are using. In 3.2 you can specify the default using the 
> "PythonOption session session_class_name" directive where 
> session_class_name is one of MemorySession, DbmSession or FileSession.
>
> Jim
>
Thanks.

I wanted to make sure I understood this since I kept getting a new sid 
every time. This was because I did not do the .save() call. Is this in 
the documentation (and I just missed it)? Or should we make it obvious 
for chumps like me?

Ognen


More information about the Mod_python mailing list