MCL Systems
mcl.office at googlemail.com
Mon Feb 4 12:54:35 EST 2008
Jim, Thank you - how stupid of me. It now works as I thought it would. Is there a default timeout and is there anywhere where best practise for session timeouts is documented. I had this daft idea of resetting timeouts, if the browser was still active. Richard On 04/02/2008, Jim Gallacher <jpg at jgassociates.ca> wrote: > > Make sure you call mySess.save(), otherwise the session is never saved > and you'll get a new session on every request. > > Jim > > MCL Systems wrote: > > I thought I was understanding sessions but the following did not work as > > I expected. > > > > I was expecting the first execution to create a session with a PID of > > 666 and a Hits Value of 1 and on each refresh of that page in the same > > browser to increment the hit counter, but the 'is_new' test, returns > > true every time. I have tried this on several computers and with > > different browsers, but always the same result. > > > > Where have I gone wrong ? > > > > Richard > > > > MOD_PYTHON, Apache, PYTHON 2.5 > > > > Code ===================================== > > from mod_python import Session, util > > > > def index(req): > > main(req) > > > > def main(req): > > mySess = Session.Session(req) > > if mySess.is_new(): > > pid = 666 > > mySess['pid'] = str(pid) > > mySess['hits'] = 1 > > req.write("NEW Session PID: %s <BR>\n" % mySess['pid']) > > req.write("Hits: %s <br>\n" % mySess['hits']) > > else: > > mySess['hits'] +=1 > > req.write("OLD Session PID: %s <BR>\n" % mySess['pid']) > > req.write("Hits: %s <br>\n" % mySess['hits']) > > > > > > ------------------------------------------------------------------------ > > > > _______________________________________________ > > Mod_python mailing list > > Mod_python at modpython.org > > http://mailman.modpython.org/mailman/listinfo/mod_python > -------------- next part -------------- An HTML attachment was scrubbed... URL: http://mm_cfg_has_not_been_edited_to_set_host_domains/pipermail/mod_python/attachments/20080204/f9e8dfc4/attachment.html
|