nutt318 Posted February 11, 2009 Share Posted February 11, 2009 Well I a page that requires a password to view the contents. Once a user logs in with this password the page times out after 5 minutes and prompt them to reenter their password. So how would I make this page after those 5 mins run another php function? Is there some sort of timer I can have that runs every 5mins without someone actually being on the page? Thanks for your help. Quote Link to comment https://forums.phpfreaks.com/topic/144806-is-there-such-thing-as-a-timer-or-only-page-refresh-time-limit/ Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 Javascript can do this for you. When it triggers you make it redirect to the logout page to log them out. Quote Link to comment https://forums.phpfreaks.com/topic/144806-is-there-such-thing-as-a-timer-or-only-page-refresh-time-limit/#findComment-759849 Share on other sites More sharing options...
nutt318 Posted February 11, 2009 Author Share Posted February 11, 2009 So using Javascript can act as a timer and say every 5mins the timer will run my code to log them out? Quote Link to comment https://forums.phpfreaks.com/topic/144806-is-there-such-thing-as-a-timer-or-only-page-refresh-time-limit/#findComment-759855 Share on other sites More sharing options...
premiso Posted February 11, 2009 Share Posted February 11, 2009 So using Javascript can act as a timer and say every 5mins the timer will run my code to log them out? If you set it that when the time is up, it uses location.href to redirect to your logout page which automatically logs them out, yes. If you want a more reliable system, you would need to store a timestamp in the DB of last activity and have a cron job run every minute checking if the activity was more than 5 minutes ago, if so kill the cookies and session which should log them out. Quote Link to comment https://forums.phpfreaks.com/topic/144806-is-there-such-thing-as-a-timer-or-only-page-refresh-time-limit/#findComment-759862 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.