Forum Moderators: coopster

Message Too Old, No Replies

php page timer

         

dragongamer

3:06 pm on Apr 10, 2006 (gmt 0)

10+ Year Member



does anyone know of a script that tells you how long you have been on a page for, i have tried cookies but with know use if any one knows an script or a site or tut?

Anyango

6:38 pm on Apr 10, 2006 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



javascript is your best bet, i question php's ability to do that

dragongamer

7:11 pm on Apr 10, 2006 (gmt 0)

10+ Year Member



i have got one but is urring the +time+ in to soing i can place in the data base? is there any way i can do it?

thanks

[edited by: coopster at 7:17 pm (utc) on April 10, 2006]
[edit reason] removed url [/edit]

coopster

7:28 pm on Apr 10, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Using PHP you will have to first establish the start time. You are right, you will have to somehow store that start time either in a cookie, a hidden form field, pass it in the query string, a session, etc. Next, when the user returns to your site you would need to grab the time again and subtract the two to get the duration. Where did your first effort fail?

dragongamer

8:33 am on Apr 11, 2006 (gmt 0)

10+ Year Member



itryed using useing cookies were it would store the time then at the end it would read it and subtrat it from the real time, but i have no real exaple fo this when i do do it just genrateds as 0.

coopster

1:27 pm on Apr 11, 2006 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



Must be something wrong in your date calculation then I would assume. Either that or the cookie is not being set and read properly. I would start by dumping the $_COOKIE data to the browser to see if the date is coming in to your script as you expect, same format, etc.

Then, test your *current* date/time retrieval process for the same.

Finally, check your substraction. If you can show the two values (begin time and end time) plus your equation perhaps we can help figure out why it always comes back as zero.