Introduction#

Flask-Session is an extension for Flask that adds support for server-side sessions to your application.

Client-side vs Server-side sessions#

Client-side sessions store session data in the client’s browser. This is done by placing it in a cookie that is sent to and from the client on each request and response. This can be any small, basic information about that client or their interactions for quick retrieval (up to 4kB).

Server-side sessions differ by storing session data in server-side storage. A cookie is also used, but it only contains the session identifier that links the client to their corresponding data on the server.

Tip

There are generally (some exceptions) no individual session size limitations for server-side sessions, but developers should be cautious about abusing this for large amounts or types of data that would be more suited for actual database storage.

Flask-Session sequence diagram#

sequence diagram for flask-session