Flask sessions not persisting on heroku

前端 未结 1 2009
星月不相逢
星月不相逢 2021-01-06 03:55

When a user logs into my sample application I add a username key into the session object and I hang a user object off of the global \"g\" object. See below.

         


        
相关标签:
1条回答
  • 2021-01-06 04:15

    Well, seeing as this indeed would be the answer due to multiple workers I'll move it from the comments part. :) You don't want redis at the gunicorn layer, rather in your application. These four links should help you out:

    1) First, enable/install Redis in Heroku

    2) Then check this out (will replace Flasks entire session driver with one based on redis): This might be overkill, I'd simply use redis as a key-storage value in the app (check my third link) but you might like this approach.

    3) Not as related but shows some usage examples (queue system for flask with redis)

    4) Basic redis tutorial for python

    These three links should get you started, if it's not enough I'll dig up some more examples so just ask if you need them!

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