| 1 |
.. image:: https://raw.githubusercontent.com/pallets-eco/flask-session/main/docs/_static/icon/favicon-192x192.png |
| 2 |
:alt: Flask-Session |
| 3 |
:target: https://flask-session.readthedocs.io |
| 4 |
:align: left |
| 5 |
:width: 60px |
| 6 |
|
| 7 |
============== |
| 8 |
Flask-Session |
| 9 |
============== |
| 10 |
|
| 11 |
Flask-Session is an extension for Flask that adds support for server-side sessions to |
| 12 |
your application. |
| 13 |
|
| 14 |
.. image:: https://img.shields.io/github/actions/workflow/status/pallets-eco/flask-session/test.yaml?logo=github |
| 15 |
:alt: GitHub Actions Workflow Status |
| 16 |
:target: https://github.com/pallets-eco/flask-session/actions/workflows/test.yaml?query=workflow%3ACI+branch%3Adevelopment |
| 17 |
|
| 18 |
.. image:: https://img.shields.io/readthedocs/flask-session?logo=readthedocs |
| 19 |
:target: https://flask-session.readthedocs.io |
| 20 |
:alt: Documentation status |
| 21 |
|
| 22 |
.. image:: https://img.shields.io/github/license/pallets-eco/flask-session?logo=bsd |
| 23 |
:target: ./LICENSE |
| 24 |
:alt: BSD-3 Clause License |
| 25 |
|
| 26 |
.. image:: https://common-changelog.org/badge.svg |
| 27 |
:target: https://common-changelog.org |
| 28 |
:alt: Common Changelog |
| 29 |
|
| 30 |
.. image:: https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json&label=style |
| 31 |
:target: https://github.com/astral-sh/ruff |
| 32 |
:alt: Code style: ruff |
| 33 |
|
| 34 |
.. image:: https://img.shields.io/pypi/v/flask-session.svg?logo=pypi |
| 35 |
:target: https://pypi.org/project/flask-session |
| 36 |
:alt: PyPI - Latest Version |
| 37 |
|
| 38 |
.. image:: https://img.shields.io/badge/dynamic/json?query=info.requires_python&label=python&logo=python&url=https%3A%2F%2Fpypi.org%2Fpypi%2Fflask-session%2Fjson |
| 39 |
:target: https://pypi.org/project/Flask-Session/ |
| 40 |
:alt: PyPI - Python Version |
| 41 |
|
| 42 |
.. image:: https://img.shields.io/discord/531221516914917387?logo=discord |
| 43 |
:target: https://discord.gg/pallets |
| 44 |
:alt: Discord |
| 45 |
|
| 46 |
.. image:: https://img.shields.io/pypi/dm/flask-session?logo=pypi |
| 47 |
:target: https://pypistats.org/packages/flask-session |
| 48 |
:alt: PyPI - Downloads |
| 49 |
|
| 50 |
Installing |
| 51 |
------------ |
| 52 |
Install and update using pip: |
| 53 |
|
| 54 |
.. code-block:: bash |
| 55 |
|
| 56 |
$ pip install flask-session |
| 57 |
|
| 58 |
A Simple Example |
| 59 |
-------------------- |
| 60 |
|
| 61 |
.. code-block:: python |
| 62 |
|
| 63 |
from flask import Flask, session |
| 64 |
from flask_session import Session |
| 65 |
|
| 66 |
app = Flask(__name__) |
| 67 |
# Check Configuration section for more details |
| 68 |
SESSION_TYPE = 'redis' |
| 69 |
app.config.from_object(__name__) |
| 70 |
Session(app) |
| 71 |
|
| 72 |
@app.route('/set/') |
| 73 |
def set(): |
| 74 |
session['key'] = 'value' |
| 75 |
return 'ok' |
| 76 |
|
| 77 |
@app.route('/get/') |
| 78 |
def get(): |
| 79 |
return session.get('key', 'not set') |
| 80 |
|
| 81 |
Supported Storage Types |
| 82 |
------------------------ |
| 83 |
- Redis |
| 84 |
- Memcached |
| 85 |
- FileSystem |
| 86 |
- MongoDB |
| 87 |
- SQLALchemy |
| 88 |
|
| 89 |
Documentation |
| 90 |
------------- |
| 91 |
Learn more at the official `Flask-Session Documentation <https://flask-session.readthedocs.io/en/latest/>`_. |
| 92 |
|
| 93 |
Maintainers |
| 94 |
------------ |
| 95 |
- `Lxstr <https://github.com/Lxstr>`_ |
| 96 |
- Pallets Team |
| 97 |
|
| 98 |
Contribute |
| 99 |
---------- |
| 100 |
Thanks to all those who have contributed to Flask-Session. A full list can be found at `CONTRIBUTORS.md <https://github.com/pallets-eco/flask-session/blob/development/CONTRIBUTORS.md>`_. |
| 101 |
|
| 102 |
If you want to contribute, please check the `CONTRIBUTING.rst <https://github.com/pallets-eco/flask-session/blob/development/CONTRIBUTING.rst>`_. |
| 103 |
|
| 104 |
Donate |
| 105 |
-------- |
| 106 |
The Pallets organization develops and supports Flask-Session and other popular packages. In order to grow the community of contributors and users, and allow the maintainers to devote more time to the projects, please donate today. |
| 107 |
|
| 108 |
|