ThePloki ThePloki - 22 days ago 4
Python Question

GAE Flask global variable persistent across browsers

Here's my Flask setup:

from flask import Flask
from app.views import main_bp

app = Flask(__name__)
app.register_blueprint(main_bp, url_prefix='')
(Shortened with "..." for this example)

'SITE_NAME': 'Test Site',
'SSL': False,
'DEBUG': True,
'LOGGED_IN': False,

from config import CONFIG

def fallback(page_slug='home'):
# Check if logged in
return 'Logged In'
return 'Logged Out'

Now if I change
in one of my browsers (Let's say Google Chrome), and then open another browser to the website (Let's say Firefox), then I'm already logged in on both. If I then log out in Firefox and refresh Chrome, I'm logged out on both.

When I was using Django I never noticed a problem like this... my global CONFIG variable is persisting across browsers. Weird!

Do I need to make my CONFIG into a class? Maybe this only happens when running through and won't happen in production? I'm still learning, so please be nice! Thanks :)

Note: Please ignore the blatant security issues with this example. I assure you this is not how I plan to use this code.


As davidism pointed out, I should not be storing variables that change per session as a global. I will instead decide on these variables after loading pertinent session variables like UID and Session ID.


Update: Athough, I find it interesting that Flask documentation would advocate setting globals via g (see: