By setting SESSION_COOKIE_AGE and turning SESSION_SAVE_EVERY_REQUEST, it will log people out after a certain time of inactivity. But is there anyway to r开发者_开发问答edirect after say 5 mins of inactivity?
You can use setTimeout()
to trigger an ajax request, and if it responds with a redirect (you have been logged out), then refresh the page. This method is superior to simply refreshing the page every 5 minutes, as that may be a bad user experience.
If you want to redirect without any action from the user, you have to do it in javascript:
setTimeout(function() { window.location.href = 'http://someURL'; }, 5 * 60 * 1000);
精彩评论