Wrox Programmer Forums
Go Back   Wrox Programmer Forums > PHP/MySQL > Pro PHP
| Search | Today's Posts | Mark Forums Read
Pro PHP Advanced PHP coding discussions. Beginning-level questions will be redirected to the Beginning PHP forum.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Pro PHP section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old July 5th, 2005, 07:20 PM
Registered User
Join Date: Feb 2005
Location: , , .
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default visitor duration per page

how would i go about working out the duration of a visitor on a page?

step 1 - i'm using a javascript img call on a website to a php script on a different server which records the event (page hit) + runs a timer to time page duration visit.

step 2 - i have also setup a javascript pageunload events which trigger a different php script to write to the db the total time spent by customer on the page when the page is closed or left. the issue i have here is how do i know / keep this customers last insert id after writting their visit in step 1 so i can push step 2 time spent duration variable into the correct row in the database? i tried cookies which didnt work and then sessions but this has intermediate outages / times it dosent work that well.

can anyone help with where i should be storing the last insert row id from the page hit?


Old September 5th, 2005, 07:50 AM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 101
Thanks: 0
Thanked 1 Time in 1 Post
Send a message via AIM to Moharo

this is how you can do it:

when user visits a page, record the timestamp of a visit.... like 1039743934 or something

when they move to other page, just generate current timestamp and subtract it from the previous visit and you get a time...


www.campusgrind.com - college portal
Old September 8th, 2005, 01:38 PM
Friend of Wrox
Join Date: Mar 2004
Location: Bhopal, MP, India.
Posts: 357
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via Yahoo to anshul

This is actually done/used for forums, blogs, carts; not for a single page.
Your script should first record time of login and then check if user is logged in, in 30 minutes or so, and increment the time.

Use Cookies? yes. Let them signout, so.

Support Indian students' finances http://scholarship.mediasworks.com/

Similar Threads
Thread Thread Starter Forum Replies Last Post
Has anyone got a visitor counter ? gb012993 BOOK: ASP.NET 2.0 Website Programming Problem Design Solution ISBN: 978-0-7645-8464-0 4 February 5th, 2008 04:01 AM
seconds-from-duration outspaced XSLT 2 April 3rd, 2007 08:51 AM
duration between dates rjkulkarni2001 Classic ASP Basics 1 January 5th, 2006 07:19 PM
HTTP_REFERER Tester Sometimes Redirects OK Visitor markw707 Classic ASP Basics 4 August 21st, 2003 11:41 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.