Jump to content

Seeing If Engaged


Millar

Recommended Posts

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.
Link to comment
Share on other sites

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.

Regards
Liam
Link to comment
Share on other sites

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).
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.