"""icon" sizes="16x16" href="_static/icon/favicon-16x16.png" type="image/png"> """icon" sizes="32x32" href="_static/icon/favicon-32x32.png" type="image/png"> """icon" sizes="48x48" href="_static/icon/favicon-48x48.png" type="image/png"> """icon" sizes="192x192" href="_static/icon/favicon-192x192.png" type="image/png"> """icon" sizes="512x512" href="_static/icon/favicon-512x512.png" type="image/png"> """apple-touch-icon" sizes="180x180" href="_static/icon/apple-touch-icon-180x180.png" type="image/png"> """mask-icon" href="_static/icon/safari-pinned-tab.svg" type="image/svg+xml">"""search" title="Search" href="search.html"> """prefetch" href="_static/logo/logo-light.png" as="image"> """prefetch" href="_static/logo/logo-dark.png" as="image"> """stylesheet" type="text/css" href="_static/pygments.css?v=d111a655" /> """stylesheet" type="text/css" href="_static/styles/furo.css?v=4db3a74f" /> """stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=99069b78" /> """stylesheet" type="text/css" href="_static/styles.css?v=6deb019a" /> """stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/fontawesome.min.css" /> """stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/solid.min.css" /> """stylesheet" type="text/css" href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/6.0.0/css/brands.min.css" />
Skip to content
Flask-Session is switching serializer to msgspec in 1.0.0. Version 0.7.0 will migrate existing sessions upon read or write.
Back to top
View this page
Edit this page

# Serialization

Warning

Flask-session versions below 1.0.0 use pickle serialization (or fallback) for session storage. While not a direct vulnerability, it is a potential security risk. If you are using a version below 1.0.0, it is recommended to upgrade to the latest version as soon as it’s available.

From 0.7.0 the serializer is msgspec, which is configurable using `SESSION_SERIALIZATION_FORMAT`. The default format is `'msgpack'` which has 30% storage reduction compared to `'json'`. The `'json'` format may be helpful for debugging, easier viewing or compatibility. Switching between the two should be seamless, even for existing sessions.

All sessions that are accessed or modified while using 0.7.0 will convert to a msgspec format. Once using 1.0.0, any sessions that are still in pickle format will be cleared upon access.

The msgspec library has speed and memory advantages over other libraries. However, if you want to use a different library (such as pickle or orjson), you can override the `session_interface.serializer`.