[mod_python] Getting an Old Session

Jeremy Kohansimeh jkohans at gmail.com
Wed Jul 13 17:45:48 EDT 2005


I have a problem where I am not able to reinstate an old Session. On initial 
login I record the session id and then check that the pysid cookie has been 
set appropriately in my browser, which it has. But, on a subsequent call 
when I try to reinstate the same session, I get a new one back that no 
longer has any of the items I have saved. I have been using the following 
code for diagnostics:

def handler(req, **kw):
"""handles initial requests"""

# used for debugging
f = open( '/home/jeremyk/public_html/data/foo.log', 'a+')

cookies = Cookie.get_cookies( req)
if cookies.has_key( 'pysid'):
pysid = cookies[ 'pysid'].value

f.write( 'pysid is ' + pysid + '\n')
req.sess = Session.Session( req, sid=pysid)
req.sess = Session.Session( req)

#req.sess = Session.Session( req)
req.sess.set_timeout( 20 * 60)
id = req.sess.id()

if not req.sess.is_new():
f.write( 'old session: ' + id + '\n')
f.write( 'new session: ' + id + '\n')


return segment.dispatchToHandler( req)

I know that I do not need to specify the sid attribute of Session for an old 
session to be reinstated (this can be determined from the request object), 
but it wasn't working when I did it that way either. Something that seems 
very strange to me is that the pysid value I get back from here does not 
match the cookie that has been set in my browser. As you can see, I set the 
timeout to 20 minutes, which is much longer than the time inbetween the 2 
calls. Is there anything else I should try?

Thanks for any help.

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20050713/f361de2f/attachment-0001.html

More information about the Mod_python mailing list