Okay so my code is below. I am dealing with apache2, mod_wsgi, beaker, python
def application(environ, start_response): session = environ['beaker.session'] if not session.has_key('value'): session['value'] = 0 session.save() try: s = session['value'] except: s = "value not found" start_response('200 OK', [('Content-type', 'text/html')]) #response = "<br />".join(environ) beaker = "<br />".join(session) try: cookie = "".join(environ['HTTP_COOKIE']) except: cookie = "" return [cookie,'<br />', str(s), '<br />', beaker, '<br /> accessed:', str(session['_accessed_time']), '<br /> creation:', str(session['_creation_time'])] from beaker.middleware import SessionMiddleware application = SessionMiddleware( application, key='mysession', secret='blah', )
After I visit my web page like localhost/file.wsgi, I'll set session['value'] and it'll be printed as you can tell from things i return. However, say once i set session['value'] and choose to comment the following area of the program,
#if not session.has_key('value'): # session['value'] = 0 #session.save()
save it, and visit localhost/file.wsgi. I had been expecting for that variable s, that is =session['value'], to obtain the value I set formerly. After I visit localhost/file.wsgi after maybe 5-just a few seconds once i change and save the file, there's no more a 'value' type in session and clearly it no more includes a value. What also changes may be the utilized time, clearly, however the creation time also changes (and achieves this after every refresh).
Note: I additionally attempted changing area of the program, the part I said out above, with
if not session.has_key('value'): session['value'] = 0 session['value'] += 1 session.save()
What went down once i transformed and utilized localhost/file.wsgi could be that the session['value'] would increment(expected), however from nowhere it might jump and make up a new session['value'] at and increment again, and essentially this could create multiple session['value']s, however the session token 'mysession' would stay. Also every couple of refreshes the worthiness would jump to another session['value'] and remain there after which jump to a different session['value'].
I'm so confused at what is happening, why the session['value'] I set does not stay set, why the creation occasions keep altering, how come there multiple masterpieces, and why did the periods jump around?
btw it was exactly the same on chrome and opera.
I am on ubuntu 10.10, python 2.6, and I am presuming the latest or round the latest versions of beaker, apache2, mod_wsgi.
Could it be my programming's problem, badly configed apache2, did not use beaker properly, what?
Thank everyone a lot.