Hi!

This is what you need :)

You have hidden frame (FRAME not layer!!!) (it means <FRAME src="check.php" height="0" [noborders etc]>)...
then in check.php would be something like this:


$id = $myid; //myid will be stored in session after user logs in
Connect to database, pair ID with a row in table and
update mytable set endtime = UNIX_TIMESTAMP() where id = myid;

do this every 2 minutes (ie with <META> refresh tag set to 120 secs)

...

if user changes page, then do following:
check, if last refresh (endtime) is less then 2 minutes ago... if so, write the new value as an endtime and set some flag to consider this session closed and then you can count the time... (if some open sessions for this user open)


Set new start time for this user and generate new frameset with frame mentioned above...

In case, that the difference between current timestamp and last endtime is 2+ minutes, time endtime + 2 minutes will be written as endtime and flags properly set to finished session ... and then start the new one... and so on...

i hope i've explained it right :)

regards,
m.

Robb Kerr wrote:

On Mon, 19 Jul 2004 15:54:14 +0200, Miroslav Hudak wrote:


I would do it this way:

- open the page and create hidden iframe (or frame with 0% width/height) which will be refreshing itself every ... let's say ... 2 minutes... then you'll get up to 2 minutes accurate numbers... the refreshed page would write timestamp to database every refresh... when the user crashes or leaves the page without logging off, you know, that his next refresh (and last one) would be LASTREFRESH + 2mins ... that gives you quite accurate numbers when implemented correctly.

On the other hand, it will be a bit load producing, while that subsequent writes to database...

Hope it helped a bit,
regards,
m.

Robb Kerr wrote:


I know that this is somewhat off topic, but I just need a starting place to
do the research and thought someone here might be able to help. I am
developing an application in which I need to time how long a visitor
remains within a module and how long they view each page. I can create the
appropriate fields in MySQL and can use PHP to do the appropriate
calcualtions. What I don't know is how I communicate this information to
the server. I can use POST or GET statements to pass info with page turns
but what do I do if the visitor leaves the site without logging out or
experiences a machine crash?

Also, if anyone knows of a good javascript newsgroup, please pass along the
info.

Thanx,
Robb


Thanx for the suggestion. Now to ask for more help... I know how to create
the layer which you mentioned. But, how do I make it auto update every few
minutes and send data to the database?

Thanx again,
Robb


-- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to