简体   繁体   English

重定向后Cookie丢失(瓶+ uWSGI + Python)

[英]Cookies getting lost after the redirect (Bottle + uWSGI + Python)

I use Bottle framework and uWSGI app server to host my website. 我使用Bottle框架和uWSGI应用服务器托管我的网站。 I'm now changing the main programming language on the website (PHP->Python) and I faced the issue: cookies I've just set using bottle.response.set_cookie() disappeared after the redirect. 我现在正在网站(PHP-> Python)上更改主要的编程语言,并且遇到了这个问题:刚使用bottle.response.set_cookie()设置的cookie在重定向后消失了。 So the full code is: 因此,完整的代码是:

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

I knew that this problem could appear, and here it is. 我知道这个问题可能会出现,就在这里。 I hadn't this problem with PHP. 我没有用PHP这个问题。 I need to set a cookie and then redirect user to the main page. 我需要设置一个cookie,然后将用户重定向到主页。 Is there any way to accomplish this properly? 有什么办法可以正确完成此任务吗?

UPD: UPD:

Temporary solution for the problem is to downgrade to 0.11.2. 该问题的临时解决方案是降级到0.11.2。

Maybe you are using a version, which is affected with this bug: 也许您使用的版本受此错误影响:

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

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

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