Millar Posted September 23, 2006 Share Posted September 23, 2006 Hello,I am writing a PHP script which involves a user being on a page for a certain amount of seconds, now, I was wondering how I can make it so when the user leaves the page, I can get a function to work. Is there anyway I can do this, maybe with sessions?Thanks, Millar. Quote Link to comment https://forums.phpfreaks.com/topic/21758-seeing-if-engaged/ Share on other sites More sharing options...
shocker-z Posted September 23, 2006 Share Posted September 23, 2006 You can't make a command excecute when exiting a page as this has to be done client side and even then in javascript its not even 90% supported i would say.. Best way is basing it on time in a DB therefore if it's been over 5 mins then user isn't on the page and if then refresh then will update the session ID time so then it now show's as being live.RegardsLiam Quote Link to comment https://forums.phpfreaks.com/topic/21758-seeing-if-engaged/#findComment-97229 Share on other sites More sharing options...
FrOzeN Posted September 23, 2006 Share Posted September 23, 2006 You could have a hidden iframe (say index.php?page=1000&page-still-open=true) in the page which refreshes itself every 1 or 2 minutes, and that information could be manipulated server-side to grasp a rough idea of what page they're currently on and how long they've been viewing it (based on the count of refreshes recorded). Quote Link to comment https://forums.phpfreaks.com/topic/21758-seeing-if-engaged/#findComment-97253 Share on other sites More sharing options...
Daniel0 Posted September 23, 2006 Share Posted September 23, 2006 If the user always goes to a specific page after, you could just run it there. Quote Link to comment https://forums.phpfreaks.com/topic/21758-seeing-if-engaged/#findComment-97256 Share on other sites More sharing options...
pkSML Posted September 23, 2006 Share Posted September 23, 2006 Millar, what is the objective with your script? What are you wanting to happen if you know a user has been on your site for N seconds? Quote Link to comment https://forums.phpfreaks.com/topic/21758-seeing-if-engaged/#findComment-97279 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.