烧瓶会议不会持续 [英] Flask Session will not Persist
问题描述
我最近部署了我的第一个Flask应用程序(实际上是有史以来第一个Web应用程序),我遇到的一个问题是没有遇到运气,这与会话有关.
I have recently deployed my first Flask application (first web application ever actually), one problem I am running into and haven't had luck tracking down is related to sessions.
我正在做的是当用户登录时设置了session['user'] = user_id
,并且发生的情况是,在发出涉及该会话密钥的请求时,我偶尔会遇到密钥错误.如果我尝试再次发出请求,则会话密钥在那里,请求工作正常.我已经进行了研究并将app.config['SERVER_NAME']
设置为我的域,并确保secret_key
是静态的,之前是动态的.
What I am doing is when the user logs in I set session['user'] = user_id
and what is happening is I occasionally get a key error when making a request involving that session key. If I try to make the request again the session key is there and the request works fine. I have done research and set the app.config['SERVER_NAME']
to my domain and made sure the secret_key
was static, it was dynamic before.
在我的本地开发服务器上不会发生这种情况,因此我有点困惑.
This does not happen when on my local development server so I am a bit stumped at this point.
推荐答案
问题是我的init包含键静态值,导致它可以在dev中工作,但在.wsgi的生产环境中仍然很动态,我已经进行了更改这一切似乎现在都在起作用.
Problem was that I had the key static in my init which caused it to work in dev but in production in the .wsgi it was still dynmaic, I have changed this and all seems to be working now.
这篇关于烧瓶会议不会持续的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!