I have an occasion where I know that the contents of a session are
invalid, and I'd like to clear the session off the disk/db and clear
the session object of an data stored in it.  Apparently
session.forget() just marks the session as being able to be cleared,
and it takes an undocumented(?) argument of the response object
currently(?) associated with the session to be cleared.  What I've
tried is:
                session.forget(response)
                session = Session()
                session.connect(request, response)
                redirect(URL(r=request, f='index'))

However this doesn't work, as it causes the Python interpreter to
think that session is now a local variable somehow(?) (I seem to be
using that a lot today!)  Just issuing a session.forget followed by
the redirect, I thought would work, but the redirect hits the same
code that tests for the existence of a variable in the session, and it
cleared the session again, then redirected again looping until the
browser reached a max recursion depth.

So how would one clear a session and allow for a redirect guaranteeing
that the variable that the redirect() call sees is clear of all
session data?

Reply via email to