Skip to content

Instantly share code, notes, and snippets.

@runfalk
Created April 26, 2012 18:52
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save runfalk/2501926 to your computer and use it in GitHub Desktop.
Save runfalk/2501926 to your computer and use it in GitHub Desktop.
JSON session cookie for Flask, instead of pickle
# Assumes app = Flask(...)
import json
from flask.sessions import SecureCookieSession, SecureCookieSessionInterface
class JSONSecureCookieSession(SecureCookieSession):
serialization_method = json
class JSONSecureCookieSessionInterface(SecureCookieSessionInterface):
session_class = JSONSecureCookieSession
app.session_interface = JSONSecureCookieSessionInterface()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment