Search code examples
pythoncherrypy

How do you listen for session expiration event in cherrypy?


I've done the setup for session timeout:

'tools.sessions.timeout': 30 'tools.sessions.on': True

Everything works fine, however, I am redirected to the login page only after I refresh the current page.

Is there a way to listen for the session expiration event and do the redirect automatically when this happens?


Solution

  • You could use javascript and setTimeout to redirect just before the session times out.

    <body onload="setTimeout('window.location = \'www.yourdomain.com\';', 1700000);">
    

    Hope this helps.

    Andrew