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
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.