Jump to content


Photo

Seeing If Engaged


  • Please log in to reply
4 replies to this topic

#1 Millar

Millar
  • Members
  • PipPipPip
  • Advanced Member
  • 40 posts
  • LocationSouthampton, UK.

Posted 23 September 2006 - 08:01 AM

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.

#2 shocker-z

shocker-z
  • Members
  • PipPipPip
  • Advanced Member
  • 864 posts
  • LocationNottingham

Posted 23 September 2006 - 01:51 PM

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
www: www.ukchat.ws | irc: irc.ukchat.ws chan: #blufudge

#3 FrOzeN

FrOzeN
  • Members
  • PipPipPip
  • Advanced Member
  • 70 posts

Posted 23 September 2006 - 02:48 PM

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).

#4 Daniel0

Daniel0
  • Staff Alumni
  • Advanced Member
  • 11,956 posts

Posted 23 September 2006 - 02:51 PM

If the user always goes to a specific page after, you could just run it there.

#5 pkSML

pkSML
  • Members
  • PipPipPip
  • Advanced Member
  • 191 posts
  • LocationBucyrus, Ohio

Posted 23 September 2006 - 03:51 PM

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?
-Stephen

Need a LitlURL?

Got code to share? --> The Code-Bin




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users