Jump to content

Archived

This topic is now archived and is closed to further replies.

Millar

Seeing If Engaged

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.

Share this post


Link to post
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

Share this post


Link to post
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).

Share this post


Link to post
Share on other sites
If the user always goes to a specific page after, you could just run it there.

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites

×

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.