Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Python Flask session for multiple instances

How can I make a flask session work across multiple instances of containers using Kubernetes? Or does Kubernetes always maintain the same container for a given session?

like image 845
Nishant Aklecha Avatar asked Oct 25 '25 15:10

Nishant Aklecha


1 Answers

Default Flask sessions are stored client-side (in the browser) as a cookie and cryptographically signed to prevent tampering. Every request to your Flask application is accompanied by this cookie. Therefore, if all running containers have the same app (at least the same secret key used for signing), then they should all have access to the same session data.

Note:

  • This is cryptographically signed, but it is not encrypted, so don't store sensitive information in the session
  • Flask-Session can be installed for server-side session support
like image 139
Brandon Fuerst Avatar answered Oct 27 '25 03:10

Brandon Fuerst