| 1 |
Introduction |
| 2 |
============= |
| 3 |
|
| 4 |
Flask-Session is an extension for `Flask`_ that adds support for server-side sessions to |
| 5 |
your application. |
| 6 |
|
| 7 |
.. _Flask: https://flask.palletsprojects.com/en/3.0.x/ |
| 8 |
|
| 9 |
Client-side vs Server-side sessions |
| 10 |
------------------------------------ |
| 11 |
|
| 12 |
Client-side sessions store session data in the client's browser. |
| 13 |
This is done by placing it in a cookie that is sent to and from the client on each request and response. |
| 14 |
This can be any small, basic information about that client or their interactions for quick retrieval (up to 4kB). |
| 15 |
|
| 16 |
Server-side sessions differ by storing session data in server-side storage. |
| 17 |
A cookie is also used, but it only contains the session identifier that links the client to their corresponding data on the server. |
| 18 |
|
| 19 |
.. tip:: |
| 20 |
There are generally (some exceptions) no individual session size limitations for server-side sessions, |
| 21 |
but developers should be cautious about abusing this for large amounts or types of data that would be more suited for actual database storage. |
| 22 |
|
| 23 |
Flask-Session sequence diagram |
| 24 |
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ |
| 25 |
|
| 26 |
.. image:: /_static/sequence.webp |
| 27 |
:alt: sequence diagram for flask-session |
| 28 |
:class: padded highlight |