Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Mesuring duration of session

Status
Not open for further replies.

effennel

Technical User
Oct 15, 2002
60
CA
Hi,

I need to log the precise duration of a session. I can log the time at session start. I do I get the time at session end if, for example, the user leaves by closing the browser?

Duration has to be precise, no timeout after x minutes...

Thanks
FnL
 
In order to catch the time at which the user closed the browser, the browser would have to interact with a script on your server at that time. There is no browser-independent way to do that.

Want the best answers? Ask the best questions!

TANSTAAFL!!
 
Here is a creative way :)

use javascript to call a script that returns a 1 pixel image on your server every minuite or so...

JavaScript
Code:
<script>
function checksession(){
var tmp=new Image;
tmp.src='webbug.php';
}
setTimeOut(1000, checksession());
</script>

PHP script webbug.php
Code:
// 1 pixel blank gif image   :)
echo base64_decode("R0lGODlhAQABAIAAAP///wAAACH5BAAAAAAALAAAAAABAAEAAAICRAEAOw==");

Of course that all depends on the fact that the person has JavaScript enabled :)

There is no really fool-proof way...

Hope that helps!


P.S. I didn't test that code.... but the idea is sound :)
 
Thanks for your help.

I like creative solutions...

Cheers,
FnL
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top