简体   繁体   English

Python Flask session 对于多个实例

[英]Python Flask session for multiple instances

How can I make a flask session work across multiple instances of containers using Kube.netes?如何使用 Kube.netes 使 flask session 跨多个容器实例工作? Or does Kube.netes always maintain the same container for a given session?或者 Kube.netes 是否始终为给定的 session 维护相同的容器?

Default Flask sessions are stored client-side (in the browser) as a cookie and cryptographically signed to prevent tampering.默认 Flask 会话作为 cookie 存储在客户端(在浏览器中)并进行加密签名以防止篡改。 Every request to your Flask application is accompanied by this cookie.对您的 Flask 应用程序的每个请求都带有此 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.因此,如果所有正在运行的容器都具有相同的应用程序(至少用于签名的密钥相同),那么它们都应该能够访问相同的 session 数据。

Note:笔记:

  • This is cryptographically signed, but it is not encrypted, so don't store sensitive information in the session这是加密签名的,但它没有加密,所以不要在 session 中存储敏感信息
  • Flask-Session can be installed for server-side session support可以安装Flask-Session用于服务器端session支持

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM