Installation#
Install from PyPI using an installer such as pip:
$ pip install Flask-Session
Flask-Session’s only required dependency is msgspec for serialization, which has no sub-dependencies.
However, you also need to choose a storage type and install an appropriate client library so the app can communicate with storage. For example, if you want to use Redis as your storage, you will need to install the redis-py library either directly or as an optional dependency like below:
$ pip install Flask-Session[redis]
Redis is the recommended storage type for Flask-Session, as it has the most complete support for the features of Flask-Session with minimal configuration.
Warning
Flask-Session versions below 1.0.0 (not yet released), use pickle as the default serializer, which may have security implications in production if your storage is ever compromised.
Available storage options#
To install Flask-Session with support for a specific storage backend, use the following command, replacing <storage-option>
with your chosen backend from the list below:
pip install Flask-Session[<storage-option>]
Available storage options and their corresponding <storage-option>
values are:
Storage |
<storage-option> |
Default client library |
Alternative client libraries |
---|---|---|---|
Redis |
|
||
Memcached |
|
||
MongoDB |
|
||
CacheLib |
|
||
SQLAlchemy |
|
||
DynamoDB |
|
Other storage backends might be compatible with Flask-Session as long as they adhere to the command interfaces used by the libraries listed above.
Cachelib#
Flask-Session also indirectly supports storage and client libraries via cachelib, which is a wrapper around various cache libraries. You must also install cachelib itselfand the relevant client library to use these.
Storage |
Client Library |
---|---|
File System |
Not required |
Simple Memory |
Not required |
UWSGI |
|
Redis |
|
Memcached |
pylibmc, python-memcached, libmc or google.appengine.api.memcached |
MongoDB |
|
DynamoDB |