Re: MySql DB access upon browser close

From: Date: Tue, 06 Jul 2004 16:36:23 +0000
Subject: Re: MySql DB access upon browser close
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-189829@lists.php.net to get a copy of this message
Hi Frank, I think you could use window.location="test.php?time=xxx" in the onUnload instead of opening a new window. Eric On Mon, 5 Jul 2004 14:08:14 -0400, Frank Voorburg <voorburg@alumni.engin.umich.edu> wrote: > Hi, > > Any help with the following is appreciated. I want to use php to store the > time that a user spent on 1 particular webpage in a mysql database. What I'm > trying to do now is: > > 1) using Javascript's OnLoad event I read out the time when the user 1st > opens the webpage > 2) using Javascript's OnUnLoad event I read out the time when the user > leaves the webpage > 3) in the same OnUnLoad event I open a new browser window using: > test.php?time=xxx, where xxx is the time difference between steps 1 and 2. > 4) In the newly opened browser window I use $_GET['time'] to read out the > time in PHP and then write it to the database. > 5) using Javascript's OnLoad event for this situation, I close the window > that I temporarily opened. > > In a nutshell, I am opening a second window, pass on the information on the > url, and then write it to the database, and finally closing the second > window again. Not the most elegant and efficient solution and I'm hoping > someone has a better suggestion/example. Perhaps something with PHP's > sessionid timeout is possible? > > Thanks, > > -Frank > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > >

« previous php.general (#189829) next »