Skip to content

Instantly share code, notes, and snippets.

@tomdottom
Created June 10, 2019 18:30
Show Gist options
  • Save tomdottom/b3dfe9c5993cc692ff9194fc4b5e6cce to your computer and use it in GitHub Desktop.
Save tomdottom/b3dfe9c5993cc692ff9194fc4b5e6cce to your computer and use it in GitHub Desktop.
How to decode flask session cookies as retrieved from the browser
from types import SimpleNamespace
from io import StringIO
from flask.sessions import SecureCookieSessionInterface
session_cookie = "... get me from your browser ..."
secret_key = "... get me from your app settings ..."
app = SimpleNamespace(secret_key=secret)
session = SecureCookieSessionInterface()
s = session.get_signing_serializer(app)
s.load(StringIO(session_cookie))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment