He could have just had all this in the layout page without calling the timeout variable from a controller function like this:
{{timeout = auth.settings.expiration}} <script> var timeout = {{=timeout}}; var time = new Date().getTime(); var refreshrate = 10000; $(document.body).bind("mousemove keypress", function(e) { time = new Date().getTime(); }); function refresh() { if(new Date().getTime() - time >= timeout*1000) { window.location.href = "{{=URL('user',args=['logout'], vars=dict(_next=URL('index')))}}"; } else { setTimeout(refresh, refreshrate); } } setTimeout(refresh, refreshrate); refresh(); </script> On Thursday, July 30, 2020 at 5:57:19 AM UTC+2, mostwanted wrote: > > The answer is here, everything i needed: > https://groups.google.com/forum/#!searchin/web2py/expiration%7Csort:date/web2py/um2Ll4vmNH4/VnYX4veOAwAJ > Thank you > > On Wednesday, July 29, 2020 at 4:15:34 PM UTC+2, villas wrote: >> >> This discussion >> <https://groups.google.com/forum/#!searchin/web2py/expiration%7Csort:date/web2py/um2Ll4vmNH4/VnYX4veOAwAJ>should >> >> help >> >> >> On Wednesday, 29 July 2020 08:41:46 UTC+1, mostwanted wrote: >>> >>> Hi guys, is there a way to force a redirect to a login page when a >>> session expires to prevent users from entering values in a page with an >>> expired session? >>> >> -- Resources: - http://web2py.com - http://web2py.com/book (Documentation) - http://github.com/web2py/web2py (Source code) - https://code.google.com/p/web2py/issues/list (Report Issues) --- You received this message because you are subscribed to the Google Groups "web2py-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to web2py+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/web2py/cb5d9474-9759-4dc4-9c19-f66e55e4cf54o%40googlegroups.com.