python - 重定向后 Cookie 丢失(Bottle + uWSGI + Python)

标签 python cookies uwsgi bottle

我使用 Bottle 框架和 uWSGI 应用服务器来托管我的网站。我现在正在更改网站上的主要编程语言(PHP->Python),并且遇到了问题:我刚刚使用 bottle.response.set_cookie() 设置的 cookie 在重定向后消失了。所以完整的代码是:

# Login page (/login)
from bottle import redirect, response # etc
...
...
response.set_cookie('cool', 'cookie') # Works good without redirect
redirect('/') # Cookie disappears 

我知道这个问题可能会出现,而且就是这样。我用PHP没有这个问题。 我需要设置一个cookie,然后将用户重定向到主页。有什么办法可以正确完成这个任务吗?

更新:

该问题的临时解决方案是降级到0.11.2。

最佳答案

也许您正在使用的版本受此错误影响:

https://github.com/defnull/bottle/issues/386

关于python - 重定向后 Cookie 丢失(Bottle + uWSGI + Python),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15710697/

相关文章:

python - 在 Python 中使用 OpenCv 转换颜色空间

python - MongoDB 计算数组中的不同项

Angular 6 和 .NET Core 2.1;浏览器不会跨端口共享 cookie

Django channel 与 uWSGI

python - Odoo 8 Python 如何分配Many2many或one2many XMLRPC创建对象

python - 如何从 [c_api.h] 向 TF_SessionRun 提供训练数据

php - Laravel DecryptException-有效负载无效

javascript - Angular JS : How to setup cookies?

uWSGI 根据环境变量设置配置

python - nginx uwsgi 和 cgi python 脚本