chinthakad
chinthakad

Reputation: 979

Handle browser's Back and Next buttons after logout Python

After log out from my app, I have redirected the user to the log in page. At the log in page, when someone click back or next buttons of the browser, I want to redirect him to the login page as same as gmail or facebook.

So I tried to clear cache as follow,

class LogoutHandler(SecurePageHandler):
def get(self):
    self.session_store.delete_cookie('session')
    self.session.clear()

    response = self.redirect('/')
    response.headers['Cache-Control'] = 'no-cache, no-store, max-age=0, must-revalidate'
    response.headers['Pragma'] = 'no-cache'
    response.headers['Expires'] = 'Fri, 01 Jan 1990 00:00:00 GMT'
    return response   

But still the back button directing me to the previous page which I logged out from.

I noted that, Referer field in the Request Headers still keeping the previous URL. So I think, I should have to override it. But I couldn't find a way to modify my Request object.

I am trying on this more than half a day and I sincerely appreciate if someone can help me.

Thanx

Upvotes: 1

Views: 908

Answers (1)

jcollado
jcollado

Reputation: 40384

Maybe you can try to use javascript's window.location.replace after logout so that the page you don't want to go back to is replace with the new login page.

Upvotes: 0

Related Questions