Reputation: 442
I use a session variable to pass some info with a redirect:
session.OrigText = XML(str(OrigText))
redirect(URL('SearchResultsOrigText'))
It arrives at the new URL / page / view - SearchResultsOrigText - and works Ok. But when from that new URL - SearchResultsOrigText- I navigate away (and it doesn't matter where I go from this new page), when returning with the 'back" button of the browser, the session.OrigText is now empty (showing as 'None').
This behaviour is happening only on PA and not locally. I do not use session.forget anywhere in my code.
Trying to pass the 'html heavy' content in the OrigText as a dictionary variable (not a session variable) gets me into another interesting issue...Python Anywhere says "Something's wrong 502- Back End". (Silent failing ?) This happens on PythonAnywhere but NOT locally as well. Sanitizing this var doesn't help...
But let's focus on the first question... Why is the session variable lost after 1.redirect and 2.leaving the new page / view - when hosted on PythonAnywhere and NOT locally ?
Thanks
Upvotes: 2
Views: 235
Reputation: 9609
I faced the same problem recently in PythonAnywhere. I solved it by deleting my domain's cookies from Firefox. I still don't know how they were messed up, though.
Upvotes: 1
Reputation: 1355
Make sure there is no "session.forget(response)" in your code or framework code along the way.
Upvotes: 0
Reputation: 5786
Flask sessions, by default use cookies, so it's possible that somewhere in your settings you have a setting for what domain to set the cookies on and that is not set correctly. It's also possible that you haven't set a secret key for sessions.
Upvotes: 1