gae-sessions icon indicating copy to clipboard operation
gae-sessions copied to clipboard

Session variables do not persist between refreshes

Open MeLight opened this issue 11 years ago • 2 comments

The most basic functionality seems to cease working. This snippet shows counter: 1 no matter how many times I refresh.

import webapp2
import sys
sys.path.insert(0, 'libs')

from libs.gaesessions import get_current_session

class TestGaeHandler(webapp2.RequestHandler):
    def get(self):
        self.post()

    def post(self):     
        session = get_current_session()
        c = session.get('counter', 0)
        session['counter'] = c+1

        counter = session['counter']
        self.response.headers['Content-Type'] = 'text/html; charset=UTF-8'
        self.response.write('counter: '+str(counter))

app = webapp2.WSGIApplication([
    ('/api/service/test_gae', TestGaeHandler)
], debug=True)

Please advise. Thanks

MeLight avatar Oct 17 '13 09:10 MeLight

Did you enable sessions in appengine_config.py?

def webapp_add_wsgi_middleware(app):
    """Called with each WSGI handler initialisation"""
    app = gaetk.gaesessions.SessionMiddleware(app, cookie_key=COOKIE_KEY)
    return app

mdornseif avatar Oct 25 '13 09:10 mdornseif

Yeap I have. Apparently it's a Google Chrome problem - because it works well on FF

MeLight avatar Nov 03 '13 12:11 MeLight