Two setups. Two different results.
Setup 1: Flask app running in develop mode, redis running in local container.
Session data persists across the requests.
Setup 2: Flask app running on an AWS EC2 instance in container with redis running in container in a docker-compose environment with an nginx container in the docker compose environment.
Some session data fails to persist between requests.
The exciting thing is that if I store the session on the cookie, the system works as expected and all state is stored in Setup 2.
Unsure about any of the following:
- why certain session items persisting and others are not.
- why this works locally repeatably and not on the EC2 instance.
- What's going wrong and (hopefully) how I fix or debug it.
UPDATE:
Session config for server side session:
PERMANENT_SESSION_LIFETIME = 600
SESSION_TYPE = 'redis'
SESSION_REDIS = redis.from_url('redis://redis')
which is part of the app configuration. Other than that, I set up flask-session with
from flask_session import Session
app = Flask(__name__)
Session(app)
(modulo the boilerplate code used to create the app.) Removing the call to Session(app)
and the config fixes the session not dropping data. I need to use redis becuase the session cookie isn't big enough to store some of the sessions.