Flask session not persisting

前端 未结 1 1464
小鲜肉
小鲜肉 2021-01-12 00:19

Am running with Python 2.7, Apache + mod_wsgi on CentOS 6.3

Things work fine when I am on localhost. However, when I run the code on a vm in Azure, I do not see the

相关标签:
1条回答
  • 2021-01-12 01:18

    Don't use app.secret_key = os.urandom(24)!

    You're supposed to enter a static value here, not read from os.urandom each time. You've probably misunderstood the example in the docs, it shows you how you can read random data from os.urandom, but it also clearly states:

    Just take that thing and copy/paste it into your code and you’re done

    If you read it at runtime, then each of your worker processes will have a different secret key! That means if a request is handled by a different worker, the session will break because the cookie is signed with the wrong secret key.

    0 讨论(0)
提交回复
热议问题