Quick StartΒΆ

Create your Flask application, load the configuration of choice, and then create the Session object by passing it the application.

The Session instance is not used for direct access, you should always use flask.session.

from flask import Flask, session
from flask_session import Session

app = Flask(__name__)
# Check Configuration section for more details
SESSION_TYPE = 'redis'

def set():
    session['key'] = 'value'
    return 'ok'

def get():
    return session.get('key', 'not set')

You may also set up your application later using init_app() method.

sess = Session()