Skip to main content

Flask Multiple Sessions Interface (combine multiple sessions with different backends)

Project description

Flask Multiple Sessions Interface

combine multiple sessions with different backends

Install it with:

pip install flask-session-plus

For Flask Multi Session to work, all you have to do is define all your sessions on a simple configuration variable called SESSION_CONFIG, and init the extension.

Session Configuration:

SESSION_CONFIG = [
    {
        'cookie_name': 'csrf',
        'session_type': 'secure_cookie',
        'session_fields': ['csrf_token'],
    },
    {
        'cookie_name': 'session',
        'session_type': 'firestore',
        'session_fields': ['user_id', 'user_data'],
    },
    # ... as many sessions as you want 
]

Caution: session_fields can collide if they have the same meaning (aka: value). If not, you must use different field names.

The above configuration will define two session interfaces. The first one is a secure cookie with 'csrf' name that will store the 'csrf_token' field.

The second one is a FirestoreSessionInterface that will store set a cookie named 'session' with a single session id. The 'user_id' and 'user_data' will be stored in the Google Cloud Firestore backend.

Register as an extension:

from flask_session_plus import Session

app = Flask(__name__)

Session(app)

or

from flask_session_plus import Session

app = Flask(__name__)

session = Session()

session.init_app(app)

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for flask-session-plus, version 0.0.1
Filename, size File type Python version Upload date Hashes
Filename, size flask_session_plus-0.0.1-py3-none-any.whl (8.3 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size flask-session-plus-0.0.1.tar.gz (6.6 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page